@@ -392,8 +392,7 @@ def layout_from_subplotspec(self, subspec,
392
392
parent = self .parent
393
393
394
394
# OK, now, we want to set the position of this subplotspec
395
- # based on its subplotspec parameters. The new gridspec will inherit.
396
-
395
+ # based on its subplotspec parameters. The new gridspec will inherit
397
396
# from gridspec. prob should be new method in gridspec
398
397
left = 0.0
399
398
right = 1.0
@@ -406,32 +405,31 @@ def layout_from_subplotspec(self, subspec,
406
405
407
406
# calculate accumulated heights of columns
408
407
cellH = totHeight / (nrows + hspace * (nrows - 1 ))
409
- sepH = hspace * cellH
408
+ sepH = hspace * cellH
410
409
411
410
if gs ._row_height_ratios is not None :
412
411
netHeight = cellH * nrows
413
- tr = float ( sum (gs ._row_height_ratios ) )
414
- cellHeights = [netHeight * r / tr for r in gs ._row_height_ratios ]
412
+ tr = sum (gs ._row_height_ratios )
413
+ cellHeights = [netHeight * r / tr for r in gs ._row_height_ratios ]
415
414
else :
416
415
cellHeights = [cellH ] * nrows
417
416
418
417
sepHeights = [0 ] + ([sepH ] * (nrows - 1 ))
419
- cellHs = np .add .accumulate (np .ravel (
420
- list (zip (sepHeights , cellHeights ))))
418
+ cellHs = np .cumsum (np .column_stack ([sepHeights , cellHeights ]).flat )
421
419
422
420
# calculate accumulated widths of rows
423
- cellW = totWidth / (ncols + wspace * (ncols - 1 ))
424
- sepW = wspace * cellW
421
+ cellW = totWidth / (ncols + wspace * (ncols - 1 ))
422
+ sepW = wspace * cellW
425
423
426
424
if gs ._col_width_ratios is not None :
427
425
netWidth = cellW * ncols
428
- tr = float ( sum (gs ._col_width_ratios ) )
426
+ tr = sum (gs ._col_width_ratios )
429
427
cellWidths = [netWidth * r / tr for r in gs ._col_width_ratios ]
430
428
else :
431
429
cellWidths = [cellW ] * ncols
432
430
433
431
sepWidths = [0 ] + ([sepW ] * (ncols - 1 ))
434
- cellWs = np .add . accumulate (np .ravel ( list ( zip ( sepWidths , cellWidths ))) )
432
+ cellWs = np .cumsum (np .column_stack ([ sepWidths , cellWidths ]). flat )
435
433
436
434
figTops = [top - cellHs [2 * rowNum ] for rowNum in range (nrows )]
437
435
figBottoms = [top - cellHs [2 * rowNum + 1 ] for rowNum in range (nrows )]
0 commit comments