FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #12651 on branch v3.0.x (FIX: ignore non-finite bbox) by meeseeksmachine · Pull Request #12668 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 3 additions & 1 deletion lib/matplotlib/axes/_base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4238,7 +4238,9 @@ def get_tightbbox(self, renderer, call_axes_locator=True,

for a in bbox_artists:
bbox = a.get_tightbbox(renderer)
if bbox is not None and (bbox.width != 0 or bbox.height != 0):
if (bbox is not None and
(bbox.width != 0 or bbox.height != 0) and
np.isfinite(bbox.width) and np.isfinite(bbox.height)):
bb.append(bbox)

_bbox = mtransforms.Bbox.union(
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5841,3 +5841,10 @@ class DummySubplot(matplotlib.axes.SubplotBase, Dummy):
FactoryDummySubplot = matplotlib.axes.subplot_class_factory(Dummy)

assert DummySubplot is FactoryDummySubplot


def test_gettightbbox_ignoreNaN():
fig, ax = plt.subplots()
t = ax.text(np.NaN, 1, 'Boo')
renderer = fig.canvas.get_renderer()
np.testing.assert_allclose(ax.get_tightbbox(renderer).width, 532.444444)

Back | FazBrowse Home | New Git URL