8000 fix special case for slope=0 · matplotlib/matplotlib@bd8e82b · GitHub
[go: up one dir, main page]

Skip to content

Commit bd8e82b

Browse files
committed
fix special case for slope=0
1 parent 45e5bc7 commit bd8e82b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/matplotlib/lines.py

Lines changed: 12 additions & 8 deletions
D9CB
Original file line numberDiff line numberDiff line change
@@ -1456,14 +1456,18 @@ def get_transform(self):
14561456
(vxlo, vylo), (vxhi, vyhi) = ax.transScale.transform(ax.viewLim)
14571457
x, y = (ax.transAxes + ax.transData.inverted()).transform(self._xy1)
14581458

1459-
# find intersections with view limits in either direction,
1460-
# and draw between the middle two points.
1461-
_, start, stop, _ = sorted([
1462-
(vxlo, y + (vxlo - x) * self._slope),
1463-
(vxhi, y + (vxhi - x) * self._slope),
1464-
(x + (vylo - y) / self._slope, vylo),
1465-
(x + (vyhi - y) / self._slope, vyhi),
1466-
])
1459+
if np.isclose(self._slope, 0):
1460+
start = vxlo, y
1461+
stop = vxhi, y
1462+
else:
1463+
# find intersections with view limits in either direction,
1464+
# and draw between the middle two points.
1465+
_, start, stop, _ = sorted([
1466+
(vxlo, y + (vxlo - x) * self._slope),
1467+
(vxhi, y + (vxhi - x) * self._slope),
1468+
(x + (vylo - y) / self._slope, vylo),
1469+
(x + (vyhi - y) / self._slope, vyhi),
1470+
])
14671471
return (BboxTransformTo(Bbox([start, stop]))
14681472
+ ax.transLimits + ax.transAxes)
14691473

0 commit comments

Comments
 (0)
0