|
18 | 18 | from .markers import MarkerStyle
|
19 | 19 | from .path import Path
|
20 | 20 | from .transforms import (
|
21 |
| - Affine2D, Bbox, BboxTransformFrom, BboxTransformTo, TransformedPath) |
| 21 | + Affine2D, Bbox, BboxTransformFrom, BboxTransformTo, TransformedPath, AffineDeltaTransform) |
22 | 22 |
|
23 | 23 | # Imported here for backward compatibility, even though they don't
|
24 | 24 | # really belong.
|
@@ -1453,23 +1453,15 @@ def __init__(self, xy1, slope, **kwargs):
|
1453 | 1453 |
|
1454 | 1454 | def get_transform(self):
|
1455 | 1455 | ax = self.axes
|
1456 |
| - (vxlo, vylo), (vxhi, vyhi) = ax.transScale.transform(ax.viewLim) |
1457 |
| - x, y = (ax.transAxes + ax.transData.inverted()).transform(self._xy1) |
| 1456 | + x, y = self._xy1 |
1458 | 1457 |
|
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 |
| - ]) |
1471 |
| - return (BboxTransformTo(Bbox([start, stop])) |
1472 |
| - + ax.transLimits + ax.transAxes) |
| 1458 | + dx, dy = AffineDeltaTransform(ax.transData + ax.transAxes.inverted()).transform([1, self._slope]) |
| 1459 | + slope_axes = dy / dx |
| 1460 | + |
| 1461 | + start = 0, slope_axes * (0 - x) + y |
| 1462 | + stop = 1, slope_axes * (1 - x) + y |
| 1463 | + |
| 1464 | + return BboxTransformTo(Bbox([start, stop])) + ax.transAxes |
1473 | 1465 |
|
1474 | 1466 |
|
1475 | 1467 | class VertexSelector:
|
|
0 commit comments