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

Commitdc81e88

Browse files
committed
works?
1 parent1bed724 commitdc81e88

File tree

5 files changed

+44
-22
lines changed

5 files changed

+44
-22
lines changed

‎lib/matplotlib/_constrained_layout.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,9 @@ def _make_layout_margins(ax, renderer, h_pad, w_pad):
268268
"""
269269
fig=ax.figure
270270
invTransFig=fig.transFigure.inverted().transform_bbox
271-
print('ax',ax,invTransFig)
272271
pos=ax.get_position(original=True)
273272
tightbbox=ax.get_tightbbox(renderer=renderer)
274-
print(pos,tightbbox)
275273
bbox=invTransFig(tightbbox)
276-
print('bbox',bbox)
277274
# this can go wrong:
278275
ifnotnp.isfinite(bbox.y0+bbox.x0+bbox.y1+bbox.x1):
279276
# just abort, this is likely a bad set of co-ordinates that

‎lib/matplotlib/axes/_base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,7 +4210,6 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
42104210
bb_xaxis=self.xaxis.get_tightbbox(renderer)
42114211
ifbb_xaxis:
42124212
bb.append(bb_xaxis)
4213-
42144213
self._update_title_position(renderer)
42154214
bb.append(self.get_window_extent(renderer))
42164215

@@ -4230,9 +4229,11 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
42304229
bbox_artists=self.get_default_bbox_extra_artists()
42314230

42324231
forainbbox_artists:
4233-
bbox=a.get_tightbbox(renderer)
4234-
ifbboxisnotNoneand (bbox.width!=0orbbox.height!=0):
4235-
bb.append(bbox)
4232+
bbox=a.get_tightbbox(renderer, )
4233+
if (bboxisnotNoneand
4234+
(bbox.width!=0orbbox.height!=0)and
4235+
np.isfinite(bbox.x0+bbox.x1+bbox.y0+bbox.y1)):
4236+
bb.append(bbox)
42364237

42374238
_bbox=mtransforms.Bbox.union(
42384239
[bforbinbbifb.width!=0orb.height!=0])

‎lib/matplotlib/axes/_secondary_axes.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222

2323

24-
def_make_secondary_locator(rect,trans,parent):
24+
def_make_secondary_locator(rect,parent):
2525
"""
2626
Helper function to locate the secondary axes.
2727
@@ -37,17 +37,18 @@ def _make_secondary_locator(rect, trans, parent):
3737
*parent*.
3838
"""
3939
_rect=mtransforms.Bbox.from_bounds(*rect)
40-
_trans=trans
4140
_parent=parent
41+
_trans=_parent.transAxes
4242

43-
definset_locator(ax,renderer):
43+
44+
defsecondary_locator(ax,renderer):
4445
bbox=_rect
4546
bb=mtransforms.TransformedBbox(bbox,_trans)
4647
tr=_parent.figure.transFigure.inverted()
4748
bb=mtransforms.TransformedBbox(bb,tr)
4849
returnbb
4950

50-
returninset_locator
51+
returnsecondary_locator
5152

5253

5354
def_parse_conversion(name,otherargs):
@@ -174,17 +175,19 @@ def set_location(self, location):
174175
else:
175176
bounds= [self._pos,0,1e-10,1]
176177

177-
transform=self._parent.transAxes
178-
secondary_locator=_make_secondary_locator(bounds,
179-
transform,self._parent)
180-
bb=secondary_locator(None,None)
178+
secondary_locator=_make_secondary_locator(bounds,self._parent)
181179

182180
# this locator lets the axes move in the parent axes coordinates.
183181
# so it never needs to know where the parent is explicitly in
184182
# figure co-ordinates.
185183
# it gets called in `ax.apply_aspect() (of all places)
186184
self.set_axes_locator(secondary_locator)
187185

186+
defapply_aspect(self,position=None):
187+
self._set_lims()
188+
super().apply_aspect(position)
189+
190+
188191
defset_ticks(self,ticks,minor=False):
189192
"""
190193
Set the x ticks with list of *ticks*
@@ -264,7 +267,7 @@ def set_conversion(self, conversion, otherargs=None):
264267
self._convert=conversion
265268
# this will track log/non log so long as the user sets...
266269
set_scale(self._parent.get_xscale())
267-
270+
268271
defdraw(self,renderer=None,inframe=False):
269272
"""
270273
Draw the secondary axes.
@@ -276,6 +279,11 @@ def draw(self, renderer=None, inframe=False):
276279
277280
"""
278281

282+
self._set_lims()
283+
super().draw(renderer=renderer,inframe=inframe)
284+
285+
def_set_lims(self):
286+
279287
ifself._orientation=='x':
280288
lims=self._parent.get_xlim()
281289
set_lim=self.set_xlim
@@ -288,9 +296,7 @@ def draw(self, renderer=None, inframe=False):
288296
ifneworder!=order:
289297
# flip because the transform will take care of the flipping..
290298
lims=lims[::-1]
291-
292299
set_lim(lims)
293-
super().draw(renderer=renderer,inframe=inframe)
294300

295301
defget_tightbbox(self,renderer,call_axes_locator=True):
296302
"""
@@ -309,12 +315,14 @@ def get_tightbbox(self, renderer, call_axes_locator=True):
309315
ifnotself.get_visible():
310316
returnNone
311317

318+
self._set_lims()
312319
locator=self.get_axes_locator()
313320
iflocatorandcall_axes_locator:
314321
pos=locator(self,renderer)
315322
self.apply_aspect(pos)
316323
else:
317324
self.apply_aspect()
325+
318326
ifself._orientation=='x':
319327
bb_axis=self.xaxis.get_tightbbox(renderer)
320328
else:
@@ -323,10 +331,10 @@ def get_tightbbox(self, renderer, call_axes_locator=True):
323331
bb.append(bb_axis)
324332

325333
bb.append(self.get_window_extent(renderer))
326-
327334
_bbox=mtransforms.Bbox.union(
328335
[bforbinbbifb.width!=0orb.height!=0])
329336

337+
330338
return_bbox
331339

332340
defset_aspect(self,*args,**kwargs):

‎lib/matplotlib/axis.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,11 +1155,10 @@ def get_tightbbox(self, renderer):
11551155
if (np.isfinite(bbox.width)andnp.isfinite(bbox.height)and
11561156
a.get_visible()):
11571157
bb.append(bbox)
1158-
11591158
bb.extend(ticklabelBoxes)
11601159
bb.extend(ticklabelBoxes2)
1161-
1162-
bb= [bforbinbbifb.width!=0orb.height!=0]
1160+
bb= [bforbinbbif ((b.width!=0orb.height!=0)and
1161+
np.isfinite(b.x0+b.y0+b.x1+b.y1))]
11631162
ifbb:
11641163
_bbox=mtransforms.Bbox.union(bb)
11651164
return_bbox

‎lib/matplotlib/figure.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,23 @@ def draw(self, renderer):
16331633
ifnotartist.get_animated()),
16341634
key=lambdaartist:artist.get_zorder())
16351635

1636+
foraxinself.axes:
1637+
locator=ax.get_axes_locator()
1638+
iflocator:
1639+
pos=locator(ax,renderer)
1640+
ax.apply_aspect(pos)
1641+
else:
1642+
ax.apply_aspect()
1643+
1644+
forchildinax.get_children():
1645+
ifhasattr(child,'apply_aspect'):
1646+
locator=child.get_axes_locator()
1647+
iflocator:
1648+
pos=locator(child,renderer)
1649+
child.apply_aspect(pos)
1650+
else:
1651+
child.apply_aspect()
1652+
16361653
try:
16371654
renderer.open_group('figure')
16381655
ifself.get_constrained_layout()andself.axes:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp