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

Skip to content

Commit ee7707b

Browse files
committed
Raise error if points are the same
1 parent 8c211c9 commit ee7707b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,10 @@ def axline(self, xy1, xy2, **kwargs):
957957
x2, y2 = xy2
958958
# If x values the same, we have a vertical line
959959
if np.allclose(x1, x2):
960+
if np.allclose(y1, y2):
961+
raise ValueError(
962+
'Cannot draw a line through two identical points '
963+
f'(got x1={x1}, x2={x2}, y1={y1}, y2={y2}).')
960964
line = self.axvline(x1, **kwargs)
961965
return line
962966

0 commit comments

Comments
 (0)