8000 axes_grid1.FloatingAxisArtistHelper.get_line is made customizable · matplotlib/matplotlib@008b765 · GitHub
[go: up one dir, main page]

Skip to content

Commit 008b765

Browse files
committed
axes_grid1.FloatingAxisArtistHelper.get_line is made customizable
svn path=/trunk/matplotlib/; revision=8782
1 parent caabbdb commit 008b765

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from matplotlib.transforms import Affine2D, IdentityTransform
1212
import numpy as np
1313

14+
from matplotlib.path import Path
15+
1416
class FixedAxisArtistHelper(AxisArtistHelper.Fixed):
1517
"""
1618
Helper class for a fixed axis.
@@ -76,6 +78,8 @@ def __init__(self, grid_helper, nth_coord, value, axis_direction=None):
7678
self.grid_helper = grid_helper
7779
self._extremes = None, None
7880

81+
self._get_line_path = None # a method that returns a Path.
82+
self._line_num_points = 100 # number of points to create a line
7983

8084
def set_extremes(self, e1, e2):
8185
self._extremes = e1, e2
@@ -125,12 +129,12 @@ def update_lim(self, axes):
125129

126130
#e1, e2 = self._extremes # ranges of other coordinates
127131
if self.nth_coord == 0:
128-
xx0 = np.linspace(self.value, self.value, 100)
129-
yy0 = np.linspace(extremes[2], extremes[3], 100)
132+
xx0 = np.linspace(self.value, self.value, self._line_num_points)
133+
yy0 = np.linspace(extremes[2], extremes[3], self._line_num_points)
130134
xx, yy = grid_finder.transform_xy(xx0, yy0)
131135
elif self.nth_coord == 1:
132-
xx0 = np.linspace(extremes[0], extremes[1], 100)
133-
yy0 = np.linspace(self.value, self.value, 100)
136+
xx0 = np.linspace(extremes[0], extremes[1], self._line_num_points)
137+
yy0 = np.linspace(self.value, self.value, self._line_num_points)
134138
xx, yy = grid_finder.transform_xy(xx0, yy0)
135139

136140
grid_info["line_xy"] = xx, yy
@@ -285,10 +289,12 @@ def get_line_transform(self, axes):
285289

286290
def get_line(self, axes):
287291
self.update_lim(axes)
288-
from matplotlib.path import Path
289-
xx, yy = self.grid_info["line_xy"]
292+
x, y = self.grid_info["line_xy"]
290293

291-
return Path(zip(xx, yy))
294+
if self._get_line_path is None:
295+
return Path(zip(x, y))
296+
else:
297+
return self._get_line_path(axes, x, y)
292298

293299

294300

0 commit comments

Comments
 (0)
0