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

Appearance settings

Commit b47faf4

Browse filesBrowse files
authored
Merge pull request #12668 from meeseeksmachine/auto-backport-of-pr-12651-on-v3.0.x
Backport PR #12651 on branch v3.0.x (FIX: ignore non-finite bbox)
2 parents af9a17b + 2095a54 commit b47faf4
Copy full SHA for b47faf4

File tree

Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4238,7 +4238,9 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
42384238

42394239
for a in bbox_artists:
42404240
bbox = a.get_tightbbox(renderer)
4241-
if bbox is not None and (bbox.width != 0 or bbox.height != 0):
4241+
if (bbox is not None and
4242+
(bbox.width != 0 or bbox.height != 0) and
4243+
np.isfinite(bbox.width) and np.isfinite(bbox.height)):
42424244
bb.append(bbox)
42434245

42444246
_bbox = mtransforms.Bbox.union(

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5841,3 +5841,10 @@ class DummySubplot(matplotlib.axes.SubplotBase, Dummy):
58415841
FactoryDummySubplot = matplotlib.axes.subplot_class_factory(Dummy)
58425842

58435843
assert DummySubplot is FactoryDummySubplot
5844+
5845+
5846+
def test_gettightbbox_ignoreNaN():
5847+
fig, ax = plt.subplots()
5848+
t = ax.text(np.NaN, 1, 'Boo')
5849+
renderer = fig.canvas.get_renderer()
5850+
np.testing.assert_allclose(ax.get_tightbbox(renderer).width, 532.444444)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.