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

Commit0593c59

Browse files
authored
Merge pull request#12660 from meeseeksmachine/auto-backport-of-pr-12635-on-v3.0.x
Backport PR#12635 on branch v3.0.x (FIX: allow non bbox_extra_artists calls)
2 parentse5bde38 +7c2b45d commit0593c59

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

‎lib/matplotlib/figure.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,9 +2271,16 @@ def get_tightbbox(self, renderer, bbox_extra_artists=None):
22712271
ifbboxisnotNoneand (bbox.width!=0orbbox.height!=0):
22722272
bb.append(bbox)
22732273

2274-
bb.extend(
2275-
ax.get_tightbbox(renderer,bbox_extra_artists=bbox_extra_artists)
2276-
foraxinself.axesifax.get_visible())
2274+
foraxinself.axes:
2275+
ifax.get_visible():
2276+
# some axes don't take the bbox_extra_artists kwarg so we
2277+
# need this conditional....
2278+
try:
2279+
bbox=ax.get_tightbbox(renderer,
2280+
bbox_extra_artists=bbox_extra_artists)
2281+
exceptTypeError:
2282+
bbox=ax.get_tightbbox(renderer)
2283+
bb.append(bbox)
22772284

22782285
iflen(bb)==0:
22792286
returnself.bbox_inches

‎lib/mpl_toolkits/axes_grid1/parasite_axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,13 @@ def _remove_method(h):
328328

329329
returnax2
330330

331-
defget_tightbbox(self,renderer,call_axes_locator=True):
331+
defget_tightbbox(self,renderer,call_axes_locator=True,
332+
bbox_extra_artists=None):
332333
bbs= [ax.get_tightbbox(renderer,call_axes_locator=call_axes_locator)
333334
foraxinself.parasites]
334335
bbs.append(super().get_tightbbox(renderer,
335-
call_axes_locator=call_axes_locator))
336+
call_axes_locator=call_axes_locator,
337+
bbox_extra_artists=bbox_extra_artists))
336338
returnBbox.union([bforbinbbsifb.width!=0orb.height!=0])
337339

338340

‎lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,18 @@ def test_image_grid():
407407
foriinrange(4):
408408
grid[i].imshow(im)
409409
grid[i].set_title('test {0}{0}'.format(i))
410+
411+
412+
deftest_gettightbbox():
413+
414+
fig,ax=plt.subplots(figsize=(8,6))
415+
416+
l,=ax.plot([1,2,3], [0,1,0])
417+
418+
ax_zoom=zoomed_inset_axes(ax,4)
419+
ax_zoom.plot([1,2,3], [0,1,0])
420+
421+
mark_inset(ax,ax_zoom,loc1=1,loc2=3,fc="none",ec='0.3')
422+
bbox=fig.get_tightbbox(fig.canvas.get_renderer())
423+
np.testing.assert_array_almost_equal(bbox.extents,
424+
[-18.022743,-14.118056,7.332813,5.4625])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp