@@ -1564,62 +1564,46 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
15641564 kw ['orientation' ] = loc_settings ['orientation' ]
15651565 location = kw ['ticklocation' ] = loc_settings ['location' ]
15661566
1567- pad = loc_settings ["pad" ]
1567+ anchor = kw .pop ('anchor' , loc_settings ['anchor' ])
1568+ panchor = kw .pop ('panchor' , loc_settings ['panchor' ])
1569+ pad = kw .pop ('pad' , loc_settings ["pad" ])
1570+ wh_space = 2 * pad / (1 - pad )
15681571
15691572 # we need to none the tree of layoutboxes because constrained_layout can't
15701573 # remove and replace the tree hierarchy w/o a segfault.
15711574 layoutbox .nonetree (parent .get_subplotspec ().get_gridspec ()._layoutbox )
1572- if location == "left" :
1573- wh_space = 2 * pad / (1 - pad )
1574- anchor = kw .pop ('anchor' , (0.0 , 0.5 ))
1575- panchor = kw .pop ('panchor' , (1.0 , 0.5 ))
1576-
1577- # for shrinking
1578- wh_ratios = [(1 - anchor [1 ])* (1 - shrink ), shrink , anchor [1 ]* (1 - shrink )]
1579-
1580- gs = parent .get_subplotspec ().subgridspec (
1581- 1 , 2 , wspace = wh_space , width_ratios = [fraction , 1 - fraction - pad ])
1582- ss_main = gs [1 ]
1583- ss_cb = gs [0 ].subgridspec (3 , 1 , hspace = 0 , height_ratios = wh_ratios )[1 ]
1584- elif location == "right" :
1585- wh_space = 2 * pad / (1 - pad )
1586- anchor = kw .pop ('anchor' , (0.0 , 0.5 ))
1587- panchor = kw .pop ('panchor' , (1.0 , 0.5 ))
15881575
1576+ if location in ('left' , 'right' ):
15891577 # for shrinking
15901578 wh_ratios = [(1 - anchor [1 ])* (1 - shrink ), shrink , anchor [1 ]* (1 - shrink )]
15911579
1592- gs = parent .get_subplotspec ().subgridspec (
1593- 1 , 2 , wspace = wh_space , width_ratios = [1 - fraction - pad , fraction ])
1594- ss_main = gs [0 ]
1595- ss_cb = gs [1 ].subgridspec (3 , 1 , hspace = 0 , height_ratios = wh_ratios )[1 ]
1596- elif location == "top" :
1597- wh_space = 2 * pad / (1 - pad )
1598- anchor = kw .pop ('anchor' , (0.5 , 1.0 ))
1599- panchor = kw .pop ('panchor' , (0.5 , 0.0 ))
1600-
1601- # for shrinking
1602- wh_ratios = [(1 - anchor [0 ])* (1 - shrink ), shrink , anchor [0 ]* (1 - shrink )]
1603-
1604- gs = parent .get_subplotspec ().subgridspec (
1605- 2 , 1 , hspace = wh_space , height_ratios = [fraction , 1 - fraction - pad ])
1606- ss_main = gs [1 ]
1607- ss_cb = gs [0 ].subgridspec (1 , 3 , wspace = 0 , width_ratios = wh_ratios )[1 ]
1608- aspect = 1 / aspect
1609- else : # "bottom"
1610- wh_space = 2 * pad / (1 - pad )
1611- anchor = kw .pop ('anchor' , (0.5 , 1.0 ))
1612- panchor = kw .pop ('panchor' , (0.5 , 0.0 ))
1613-
1580+ if location == 'left' :
1581+ gs = parent .get_subplotspec ().subgridspec (
1582+ 1 , 2 , wspace = wh_space , width_ratios = [fraction , 1 - fraction - pad ])
1583+ ss_main = gs [1 ]
1584+ ss_cb = gs [0 ].subgridspec (3 , 1 , hspace = 0 , height_ratios = wh_ratios )[1 ]
1585+ else :
1586+ gs = parent .get_subplotspec ().subgridspec (
1587+ 1 , 2 , wspace = wh_space , width_ratios = [1 - fraction - pad , fraction ])
1588+ ss_main = gs [0 ]
1589+ ss_cb = gs [1 ].subgridspec (3 , 1 , hspace = 0 , height_ratios = wh_ratios )[1 ]
1590+ else :
16141591 # for shrinking
16151592 wh_ratios = [anchor [0 ]* (1 - shrink ), shrink , (1 - anchor [0 ])* (1 - shrink )]
16161593
1617- gs = parent .get_subplotspec ().subgridspec (
1618- 2 , 1 , hspace = wh_space , height_ratios = [1 - fraction - pad , fraction ])
1619- ss_main = gs [0 ]
1620- ss_cb = gs [1 ].subgridspec (1 , 3 , wspace = 0 , width_ratios = wh_ratios )[1 ]
1621- aspect = 1 / aspect
1622-
1594+ if location == 'bottom' :
1595+ gs = parent .get_subplotspec ().subgridspec (
1596+ 2 , 1 , hspace = wh_space , height_ratios = [1 - fraction - pad , fraction ])
1597+ ss_main = gs [0 ]
1598+ ss_cb = gs [1 ].subgridspec (1 , 3 , wspace = 0 , width_ratios = wh_ratios )[1 ]
1599+ aspect = 1 / aspect
1600+ else :
1601+ gs = parent .get_subplotspec ().subgridspec (
1602+ 2 , 1 , hspace = wh_space , height_ratios = [fraction , 1 - fraction - pad ])
1603+ ss_main = gs [1 ]
1604+ ss_cb = gs [0 ].subgridspec (1 , 3 , wspace = 0 , width_ratios = wh_ratios )[1 ]
1605+ aspect = 1 / aspect
1606+
16231607 parent .set_subplotspec (ss_main )
16241608 parent .update_params ()
16251609 parent ._set_position (parent .figbox )
0 commit comments