@@ -2011,42 +2011,23 @@ def _redo_transform_rel_fig(self, bbox=None):
2011
2011
If not None, then the bbox is used for relative bounding box.
2012
2012
Otherwise it is calculated from the subplotspec.
2013
2013
"""
2014
-
2015
2014
if bbox is not None :
2016
2015
self .bbox_relative .p0 = bbox .p0
2017
2016
self .bbox_relative .p1 = bbox .p1
2018
2017
return
2019
-
2020
- gs = self ._subplotspec .get_gridspec ()
2021
2018
# need to figure out *where* this subplotspec is.
2022
- wr = gs .get_width_ratios ()
2023
- hr = gs .get_height_ratios ()
2024
- nrows , ncols = gs .get_geometry ()
2025
- if wr is None :
2026
- wr = np .ones (ncols )
2027
- else :
2028
- wr = np .array (wr )
2029
- if hr is None :
2030
- hr = np .ones (nrows )
2031
- else :
2032
- hr = np .array (hr )
2033
- widthf = np .sum (wr [self ._subplotspec .colspan ]) / np .sum (wr )
2034
- heightf = np .sum (hr [self ._subplotspec .rowspan ]) / np .sum (hr )
2035
-
2036
- x0 = 0
2037
- if not self ._subplotspec .is_first_col ():
2038
- x0 += np .sum (wr [:self ._subplotspec .colspan .start ]) / np .sum (wr )
2039
-
2040
- y0 = 0
2041
- if not self ._subplotspec .is_last_row ():
2042
- y0 += 1 - (np .sum (hr [:self ._subplotspec .rowspan .stop ]) /
2043
- np .sum (hr ))
2044
-
2019
+ gs = self ._subplotspec .get_gridspec ()
2020
+ wr = np .asarray (gs .get_width_ratios ())
2021
+ hr = np .asarray (gs .get_height_ratios ())
2022
+ dx = wr [self ._subplotspec .colspan ].sum () / wr .sum ()
2023
+ dy = hr [self ._subplotspec .rowspan ].sum () / hr .sum ()
2024
+ x0 = wr [:self ._subplotspec .colspan .start ].sum () / wr .sum ()
2025
+ y0 = 1 - hr [:self ._subplotspec .rowspan .stop ].sum () / hr .sum ()
2045
2026
if self .bbox_relative is None :
2046
- self .bbox_relative = Bbox .from_bounds (x0 , y0 , widthf , heightf )
2027
+ self .bbox_relative = Bbox .from_bounds (x0 , y0 , dx , dy )
2047
2028
else :
2048
2029
self .bbox_relative .p0 = (x0 , y0 )
2049
- self .bbox_relative .p1 = (x0 + widthf , y0 + heightf )
2030
+ self .bbox_relative .p1 = (x0 + dx , y0 + dy )
2050
2031
2051
2032
def get_constrained_layout (self ):
2052
2033
"""
0 commit comments