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

Skip to content

Commit 403edba

Browse files
committed
Merge pull request #4535 from tacaswell/fix_nan_in_text
FIX: move infinite position check in text.draw
2 parents 0552724 + 2126a43 commit 403edba

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/matplotlib/text.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ def draw(self, renderer):
741741
# position in Text, and dash position in TextWithDash:
742742
posx = float(textobj.convert_xunits(textobj._x))
743743
posy = float(textobj.convert_yunits(textobj._y))
744-
744+
if not np.isfinite(posx) or not np.isfinite(posy):
745+
raise ValueError("posx and posy should be finite values")
745746
posx, posy = trans.transform_point((posx, posy))
746747
canvasw, canvash = renderer.get_canvas_width_height()
747748

@@ -760,8 +761,6 @@ def draw(self, renderer):
760761
angle = textobj.get_rotation()
761762

762763
for line, wh, x, y in info:
763-
if not np.isfinite(x) or not np.isfinite(y):
764-
continue
765764

766765
mtext = textobj if len(info) == 1 else None
767766
x = x + posx

0 commit comments

Comments
 (0)