Skip to content

Commit d95d80d

Browse files
committed
FIX: Ignore spines if using tight_layout
1 parent 4bc1ca9 commit d95d80d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/tight_layout.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ def auto_adjust_subplotpars(
176176
margin_right = 0.4999
177177
warnings.warn('The left and right margins cannot be made large '
178178
'enough to accommodate all axes decorations. ')
179+
return None
179180
if margin_bottom + margin_top >= 1:
180181
margin_bottom = 0.4999
181182
margin_top = 0.4999
182183
warnings.warn('The bottom and top margins cannot be made large '
183184
'enough to accommodate all axes decorations. ')
185+
return None
184186

185187
kwargs = dict(left=margin_left,
186188
right=1 - margin_right,
@@ -302,7 +304,10 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
302304
for ax, subplotspec in zip(axes_list, subplotspec_list):
303305
if subplotspec is None:
304306
continue
305-
307+
# spines have a problem under zoom; CL ignores zoom events. TL
308+
# ignores spines...
309+
for spine in ['left', 'right', 'bottom', 'top']:
310+
ax.spines[spine].set_in_layout(False)
306311
subplots = subplot_dict.setdefault(subplotspec, [])
307312

308313
if not subplots:
@@ -354,6 +359,8 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
354359
subplot_list=subplot_list,
355360
ax_bbox_list=ax_bbox_list,
356361
pad=pad, h_pad=h_pad, w_pad=w_pad)
362+
if kwargs is None:
363+
return None
357364

358365
if rect is not None:
359366
# if rect is given, the whole subplots area (including
@@ -384,5 +391,7 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
384391
ax_bbox_list=ax_bbox_list,
385392
pad=pad, h_pad=h_pad, w_pad=w_pad,
386393
rect=(left, bottom, right, top))
394+
if kwargs is None:
395+
return None
387396

388397
return kwargs

0 commit comments

Comments
 (0)