Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 130a327

Browse files
authored
Merge pull request #15482 from anntzer/constrained-style
Trivial style fixes to constrained_layout.
2 parents f1eadea + 3eb277f commit 130a327

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

lib/matplotlib/_constrained_layout.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,9 @@ def _make_layout_margins(ax, renderer, h_pad, w_pad):
287287
w_padt = ax._poslayoutbox.w_pad
288288
if w_padt is None:
289289
w_padt = w_pad
290-
ax._poslayoutbox.edit_left_margin_min(-bbox.x0 +
291-
pos.x0 + w_padt)
292-
ax._poslayoutbox.edit_right_margin_min(bbox.x1 -
293-
pos.x1 + w_padt)
294-
ax._poslayoutbox.edit_bottom_margin_min(
295-
-bbox.y0 + pos.y0 + h_padt)
290+
ax._poslayoutbox.edit_left_margin_min(-bbox.x0 + pos.x0 + w_padt)
291+
ax._poslayoutbox.edit_right_margin_min(bbox.x1 - pos.x1 + w_padt)
292+
ax._poslayoutbox.edit_bottom_margin_min(-bbox.y0 + pos.y0 + h_padt)
296293
ax._poslayoutbox.edit_top_margin_min(bbox.y1-pos.y1+h_padt)
297294
_log.debug('left %f', (-bbox.x0 + pos.x0 + w_pad))
298295
_log.debug('right %f', (bbox.x1 - pos.x1 + w_pad))
@@ -309,8 +306,7 @@ def _make_layout_margins(ax, renderer, h_pad, w_pad):
309306
ax._layoutbox.constrain_height_min(20, strength='weak')
310307
ax._layoutbox.constrain_width_min(20, strength='weak')
311308
ax._poslayoutbox.constrain_top_margin(0, strength='weak')
312-
ax._poslayoutbox.constrain_bottom_margin(0,
313-
strength='weak')
309+
ax._poslayoutbox.constrain_bottom_margin(0, strength='weak')
314310
ax._poslayoutbox.constrain_right_margin(0, strength='weak')
315311
ax._poslayoutbox.constrain_left_margin(0, strength='weak')
316312

@@ -332,12 +328,10 @@ def _align_spines(fig, gs):
332328
height_ratios = np.ones(nrows)
333329

334330
# get axes in this gridspec....
335-
axs = []
336-
for ax in fig.axes:
337-
if (hasattr(ax, 'get_subplotspec')
338-
and ax._layoutbox is not None):
339-
if ax.get_subplotspec().get_gridspec() == gs:
340-
axs += [ax]
331+
axs = [ax for ax in fig.axes
332+
if (hasattr(ax, 'get_subplotspec')
333+
and ax._layoutbox is not None
334+
and ax.get_subplotspec().get_gridspec() == gs)]
341335
rownummin = np.zeros(len(axs), dtype=np.int8)
342336
rownummax = np.zeros(len(axs), dtype=np.int8)
343337
colnummin = np.zeros(len(axs), dtype=np.int8)
@@ -379,15 +373,12 @@ def _align_spines(fig, gs):
379373
if not alignleft and colnum0min == colnumCmin:
380374
# we want the _poslayoutboxes to line up on left
381375
# side of the axes spines...
382-
layoutbox.align([ax._poslayoutbox,
383-
axc._poslayoutbox],
376+
layoutbox.align([ax._poslayoutbox, axc._poslayoutbox],
384377
'left')
385378
alignleft = True
386-
387379
if not alignright and colnum0max == colnumCmax:
388380
# line up right sides of _poslayoutbox
389-
layoutbox.align([ax._poslayoutbox,
390-
axc._poslayoutbox],
381+
layoutbox.align([ax._poslayoutbox, axc._poslayoutbox],
391382
'right')
392383
alignright = True
393384
# Vertically align axes spines if they have the
@@ -398,7 +389,6 @@ def _align_spines(fig, gs):
398389
layoutbox.align([ax._poslayoutbox, axc._poslayoutbox],
399390
'top')
400391
aligntop = True
401-
402392
if not alignbot and rownum0max == rownumCmax:
403393
# line up bottom of _poslayoutbox
404394
_log.debug('rownum0max == rownumCmax')

0 commit comments

Comments
 (0)