8000 In text, warn and return instead of raise exception for non-finite x, y · matplotlib/matplotlib@b6950df · GitHub
[go: up one dir, main page]

Skip to content

Commit b6950df

Browse files
committed
In text, warn and return instead of raise exception for non-finite x, y
1 parent 790c843 commit b6950df

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/text.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,12 @@ def draw(self, renderer):
759759
# position in Text, and dash position in TextWithDash:
760760
posx = float(textobj.convert_xunits(textobj._x))
761761
posy = float(textobj.convert_yunits(textobj._y))
762-
if not np.isfinite(posx) or not np.isfinite(posy):
763-
raise ValueError("posx and posy should be finite values")
764762
posx, posy = trans.transform_point((posx, posy))
763+
if not np.isfinite(posx) or not np.isfinite(posy):
764+
warnst = "x and y are not finite values for text "
765+
warnst += "string '%s'. Not rendering text."
766+
warnings.warn(warnst%self.get_text())
767+
return
765768
canvasw, canvash = renderer.get_canvas_width_height()
766769

767770
# draw the FancyBboxPatch

0 commit comments

Comments
 (0)
0