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

Skip to content

Commit 1bed724

Browse files
committed
Fixing
1 parent b1f36d6 commit 1bed724

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

lib/matplotlib/_constrained_layout.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def do_constrained_layout(fig, renderer, h_pad, w_pad,
181181
sup = fig._suptitle
182182
bbox = invTransFig(sup.get_window_extent(renderer=renderer))
183183
height = bbox.y1 - bbox.y0
184-
sup._layoutbox.edit_height(height+h_pad)
184+
if np.isfinite(height):
185+
sup._layoutbox.edit_height(height+h_pad)
185186

186187
# OK, the above lines up ax._poslayoutbox with ax._layoutbox
187188
# now we need to
@@ -267,10 +268,17 @@ def _make_layout_margins(ax, renderer, h_pad, w_pad):
267268
"""
268269
fig = ax.figure
269270
invTransFig = fig.transFigure.inverted().transform_bbox
270-
271+
print('ax', ax, invTransFig)
271272
pos = ax.get_position(original=True)
272273
tightbbox = ax.get_tightbbox(renderer=renderer)
274+
print(pos, tightbbox)
273275
bbox = invTransFig(tightbbox)
276+
print('bbox', bbox)
277+
# this can go wrong:
278+
if not np.isfinite(bbox.y0 + bbox.x0 + bbox.y1 + bbox.x1):
279+
# just abort, this is likely a bad set of co-ordinates that
280+
# is transitory...
281+
return
274282
# use stored h_pad if it exists
275283
h_padt = ax._poslayoutbox.h_pad
276284
if h_padt is None:
@@ -288,6 +296,8 @@ def _make_layout_margins(ax, renderer, h_pad, w_pad):
288296
_log.debug('left %f', (-bbox.x0 + pos.x0 + w_pad))
289297
_log.debug('right %f', (bbox.x1 - pos.x1 + w_pad))
290298
_log.debug('bottom %f', (-bbox.y0 + pos.y0 + h_padt))
299+
_log.debug('bbox.y0 %f', bbox.y0)
300+
_log.debug('pos.y0 %f', pos.y0)
291301
# Sometimes its possible for the solver to collapse
292302
# rather than expand axes, so they all have zero height
293303
# or width. This stops that... It *should* have been

lib/matplotlib/axes/_secondary_axes.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def __init__(self, parent, orientation,
8989
self._axis = self.yaxis
9090
self._locstrings = ['right', 'left']
9191
self._otherstrings = ['top', 'bottom']
92+
# this gets positioned w/o constrained_layout so exclude:
93+
self._layoutbox = None
94+
self._poslayoutbox = None
9295

9396
self.set_location(location)
9497
self.set_conversion(conversion, self._otherargs)
@@ -241,10 +244,11 @@ def set_conversion(self, conversion, otherargs=None):
241244
# make the _convert function...
242245
if isinstance(conversion, mtransforms.Transform):
243246
self._convert = conversion
244-
set_scale('arbitrary', transform=conversion.inverted())
247+
248+
self.set_xscale('arbitrary', transform=conversion.inverted())
245249
elif isinstance(conversion, str):
246250
self._convert = _parse_conversion(conversion, otherargs)
247-
set_scale('arbitrary', transform=self._convert.inverted())
251+
self.set_xscale('arbitrary', transform=self._convert.inverted())
248252
else:
249253
# linear conversion with offset
250254
if isinstance(conversion, numbers.Number):
@@ -271,29 +275,19 @@ def draw(self, renderer=None, inframe=False):
271275
parameter when axes initialized.)
272276
273277
"""
274-
# check parent scale... Make these match....
275-
if self._orientation == 'x':
276-
scale = self._parent.get_xscale()
277-
self.set_xscale(scale)
278-
if self._orientation == 'y':
279-
scale = self._parent.get_yscale()
280-
self.set_yscale(scale)
281278

282279
if self._orientation == 'x':
283280
lims = self._parent.get_xlim()
284281
set_lim = self.set_xlim
285282
if self._orientation == 'y':
286283
lims = self._parent.get_ylim()
287284
set_lim = self.set_ylim
288-
print('parent', lims)
289285
order = lims[0] < lims[1]
290286
lims = self._convert.transform(lims)
291287
neworder = lims[0] < lims[1]
292288
if neworder != order:
293289
# flip because the transform will take care of the flipping..
294-
# lims = lims[::-1]
295-
pass
296-
print('childs', lims)
290+
lims = lims[::-1]
297291

298292
set_lim(lims)
299293
super().draw(renderer=renderer, inframe=inframe)
@@ -480,9 +474,7 @@ def __init__(self, fac):
480474
self._fac = fac
481475

482476
def transform_non_affine(self, values):
483-
with np.errstate(divide="ignore", invalid="ignore"):
484-
q = self._fac / values
485-
print('q', values, q)
477+
q = self._fac / values
486478
return q
487479

488480
def inverted(self):
@@ -555,7 +547,6 @@ def get_transform(self):
555547
The transform for linear scaling is just the
556548
:class:`~matplotlib.transforms.IdentityTransform`.
557549
"""
558-
print('tranform', self._transform)
559550
return self._transform
560551

561552
def set_default_locators_and_formatters(self, axis):

0 commit comments

Comments
 (0)