Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit70e7d18

Browse files
committed
FIX: Stop tight layout collapsing under zoom
1 parent4bc1ca9 commit70e7d18

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

‎lib/matplotlib/figure.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,13 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
23472347
from .tight_layoutimport (
23482348
get_renderer,get_subplotspec_list,get_tight_layout_figure)
23492349

2350+
try:
2351+
ifself.canvas.toolbar._activein ('PAN','ZOOM'):
2352+
# don't do tight layout during zoom and pan.
2353+
return
2354+
exceptAttributeError:
2355+
# not toolbar, or no _active attribute..
2356+
pass
23502357
subplotspec_list=get_subplotspec_list(self.axes)
23512358
ifNoneinsubplotspec_list:
23522359
warnings.warn("This figure includes Axes that are not compatible "
@@ -2358,7 +2365,8 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
23582365
kwargs=get_tight_layout_figure(
23592366
self,self.axes,subplotspec_list,renderer,
23602367
pad=pad,h_pad=h_pad,w_pad=w_pad,rect=rect)
2361-
self.subplots_adjust(**kwargs)
2368+
ifkwargsisnotNone:
2369+
self.subplots_adjust(**kwargs)
23622370

23632371
defalign_xlabels(self,axs=None):
23642372
"""

‎lib/matplotlib/gridspec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ def tight_layout(self, figure, renderer=None,
326326
kwargs=tight_layout.get_tight_layout_figure(
327327
figure,figure.axes,subplotspec_list,renderer,
328328
pad=pad,h_pad=h_pad,w_pad=w_pad,rect=rect)
329-
self.update(**kwargs)
329+
ifkwargsisnotNone:
330+
self.update(**kwargs)
330331

331332

332333
classGridSpecFromSubplotSpec(GridSpecBase):

‎lib/matplotlib/tight_layout.py

Lines changed: 6 additions & 0 deletions
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+
returnNone
179180
ifmargin_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+
returnNone
184186

185187
kwargs=dict(left=margin_left,
186188
right=1-margin_right,
@@ -354,6 +356,8 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
354356
subplot_list=subplot_list,
355357
ax_bbox_list=ax_bbox_list,
356358
pad=pad,h_pad=h_pad,w_pad=w_pad)
359+
ifkwargsisNone:
360+
returnNone
357361

358362
ifrectisnotNone:
359363
# if rect is given, the whole subplots area (including
@@ -384,5 +388,7 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
384388
ax_bbox_list=ax_bbox_list,
385389
pad=pad,h_pad=h_pad,w_pad=w_pad,
386390
rect=(left,bottom,right,top))
391+
ifkwargsisNone:
392+
returnNone
387393

388394
returnkwargs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp