Skip to content

Commit f5452a6

Browse files
committed
validate if Bbox is null
1 parent ddfa661 commit f5452a6

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ lib/z.lib
106106

107107
# Environments #
108108
################
109-
.env
110109
.venv
111110
env/
112111
venv/
@@ -125,3 +124,5 @@ lib/matplotlib/backends/web_backend/node_modules/
125124
lib/matplotlib/backends/web_backend/package-lock.json
126125

127126
LICENSE/LICENSE_QHULL
127+
config.bat
128+
node_modules

lib/matplotlib/backends/web_backend/.eslintrc.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/matplotlib/text.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,10 +1625,18 @@ def _check_xy(self, renderer=None):
16251625
if renderer is None:
16261626
renderer = self.get_figure(root=True)._get_renderer()
16271627
b = self.get_annotation_clip()
1628+
not_none = (b is None and
1629+
callable(self.xycoords) and
1630+
self.xycoords(renderer) is not None)
16281631
if b or (b is None and self.xycoords == "data"):
16291632
# check if self.xy is inside the Axes.
16301633
xy_pixel = self._get_position_xy(renderer)
16311634
return self.axes.contains_point(xy_pixel)
1635+
1636+
if not_none:
1637+
if self.xycoords(renderer).is_null():
1638+
return False
1639+
16321640
return True
16331641

16341642
def _check_xytext(self, renderer=None):

lib/matplotlib/transforms.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,14 @@ def frozen(self):
783783
frozen_bbox._minpos = self.minpos.copy()
784784
return frozen_bbox
785785

786+
def is_null(self):
787+
"""
788+
Return True if this bbox is a 'null' bbox, i.e.
789+
[[inf, inf], [-inf, -inf]].
790+
"""
791+
return (np.isposinf(self.x0) and np.isposinf(self.y0) and
792+
np.isneginf(self.x1) and np.isneginf(self.y1))
793+
786794
@staticmethod
787795
def unit():
788796
"""Create a new unit `Bbox` from (0, 0) to (1, 1)."""

0 commit comments

Comments
 (0)