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

Skip to content

Commit b6a6414

Browse files
authored
Merge pull request #20206 from anntzer/aagi
Cleanup axisartist in preparation for future changes.
2 parents 89a699b + df93fed commit b6a6414

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The ``grid_info`` attribute of ``axisartist`` classes
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... has been deprecated.

lib/mpl_toolkits/axisartist/floating_axes.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ def __init__(self, grid_helper, side, nth_coord_ticks=None):
4444

4545
def update_lim(self, axes):
4646
self.grid_helper.update_lim(axes)
47-
self.grid_info = self.grid_helper.grid_info
47+
self._grid_info = self.grid_helper._grid_info
4848

4949
def get_tick_iterators(self, axes):
5050
"""tick_loc, tick_angle, tick_label, (optionally) tick_label"""
5151

5252
grid_finder = self.grid_helper.grid_finder
5353

54-
lat_levs, lat_n, lat_factor = self.grid_info["lat_info"]
55-
lon_levs, lon_n, lon_factor = self.grid_info["lon_info"]
54+
lat_levs, lat_n, lat_factor = self._grid_info["lat_info"]
55+
lon_levs, lon_n, lon_factor = self._grid_info["lon_info"]
5656

5757
lon_levs, lat_levs = np.asarray(lon_levs), np.asarray(lat_levs)
5858
if lat_factor is not None:
@@ -94,7 +94,7 @@ def transform_xy(x, y):
9494
xx2a, yy2a = transform_xy(xx0, yy00)
9595
xx2b, yy2b = transform_xy(xx0, yy00 + dy)
9696

97-
labels = self.grid_info["lat_labels"]
97+
labels = self._grid_info["lat_labels"]
9898
labels = [l for l, m in zip(labels, mask) if m]
9999

100100
elif self.nth_coord == 1:
@@ -113,7 +113,7 @@ def transform_xy(x, y):
113113
xx2a, yy2a = transform_xy(xx00, yy0)
114114
xx2b, yy2b = transform_xy(xx00 + dx, yy0)
115115

116-
labels = self.grid_info["lon_labels"]
116+
labels = self._grid_info["lon_labels"]
117117
labels = [l for l, m in zip(labels, mask) if m]
118118

119119
def f1():
@@ -138,7 +138,7 @@ def get_line(self, axes):
138138
right=("lon_lines0", 1),
139139
bottom=("lat_lines0", 0),
140140
top=("lat_lines0", 1))[self._side]
141-
xx, yy = self.grid_info[k][v]
141+
xx, yy = self._grid_info[k][v]
142142
return Path(np.column_stack([xx, yy]))
143143

144144

@@ -229,10 +229,10 @@ def new_fixed_axis(self, loc,
229229
# return axis
230230

231231
def _update_grid(self, x1, y1, x2, y2):
232-
if self.grid_info is None:
233-
self.grid_info = dict()
232+
if self._grid_info is None:
233+
self._grid_info = dict()
234234

235-
grid_info = self.grid_info
235+
grid_info = self._grid_info
236236

237237
grid_finder = self.grid_finder
238238
extremes = grid_finder.extreme_finder(grid_finder.inv_transform_xy,
@@ -284,9 +284,9 @@ def _update_grid(self, x1, y1, x2, y2):
284284
def get_gridlines(self, which="major", axis="both"):
285285
grid_lines = []
286286
if axis in ["both", "x"]:
287-
grid_lines.extend(self.grid_info["lon_lines"])
287+
grid_lines.extend(self._grid_info["lon_lines"])
288288
if axis in ["both", "y"]:
289-
grid_lines.extend(self.grid_info["lat_lines"])
289+
grid_lines.extend(self._grid_info["lat_lines"])
290290
return grid_lines
291291

292292
def get_boundary(self):

lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import numpy as np
77

8+
from matplotlib import _api
89
from matplotlib.path import Path
910
from matplotlib.transforms import Affine2D, IdentityTransform
1011
from .axislines import AxisArtistHelper, GridHelperBase
@@ -75,19 +76,17 @@ def get_tick_iterators(self, axes):
7576

7677

7778
class FloatingAxisArtistHelper(AxisArtistHelper.Floating):
79+
grid_info = _api.deprecate_privatize_attribute("3.5")
7880

7981
def __init__(self, grid_helper, nth_coord, value, axis_direction=None):
8082
"""
8183
nth_coord = along which coordinate value varies.
8284
nth_coord = 0 -> x axis, nth_coord = 1 -> y axis
8385
"""
84-
8586
super().__init__(nth_coord, value)
8687
self.value = value
8788
self.grid_helper = grid_helper
8889
self._extremes = -np.inf, np.inf
89-
90-
self._get_line_path = None # a method that returns a Path.
9190
self._line_num_points = 100 # number of points to create a line
9291

9392
def set_extremes(self, e1, e2):
@@ -129,7 +128,7 @@ def update_lim(self, axes):
129128
yy0 = np.full(self._line_num_points, self.value)
130129
xx, yy = grid_finder.transform_xy(xx0, yy0)
131130

132-
self.grid_info = {
131+
self._grid_info = {
133132
"extremes": (lon_min, lon_max, lat_min, lat_max),
134133
"lon_info": (lon_levs, lon_n, lon_factor),
135134
"lat_info": (lat_levs, lat_n, lat_factor),
@@ -145,7 +144,7 @@ def get_axislabel_transform(self, axes):
145144

146145
def get_axislabel_pos_angle(self, axes):
147146

148-
extremes = self.grid_info["extremes"]
147+
extremes = self._grid_info["extremes"]
149148

150149
if self.nth_coord == 0:
151150
xx0 = self.value
@@ -180,12 +179,12 @@ def get_tick_iterators(self, axes):
180179

181180
grid_finder = self.grid_helper.grid_finder
182181

183-
lat_levs, lat_n, lat_factor = self.grid_info["lat_info"]
182+
lat_levs, lat_n, lat_factor = self._grid_info["lat_info"]
184183
lat_levs = np.asarray(lat_levs)
185184
yy0 = lat_levs / lat_factor
186185
dy = 0.01 / lat_factor
187186

188-
lon_levs, lon_n, lon_factor = self.grid_info["lon_info"]
187+
lon_levs, lon_n, lon_factor = self._grid_info["lon_info"]
189188
lon_levs = np.asarray(lon_levs)
190189
xx0 = lon_levs / lon_factor
191190
dx = 0.01 / lon_factor
@@ -221,7 +220,7 @@ def transform_xy(x, y):
221220
xx2a, yy2a = transform_xy(xx0, yy0)
222221
xx2b, yy2b = transform_xy(xx0, yy0+dy)
223222

224-
labels = self.grid_info["lat_labels"]
223+
labels = self._grid_info["lat_labels"]
225224
labels = [l for l, m in zip(labels, mask) if m]
226225

227226
elif self.nth_coord == 1:
@@ -237,7 +236,7 @@ def transform_xy(x, y):
237236
xx2a, yy2a = transform_xy(xx00, yy0)
238237
xx2b, yy2b = transform_xy(xx00+dx, yy0)
239238

240-
labels = self.grid_info["lon_labels"]
239+
labels = self._grid_info["lon_labels"]
241240
labels = [l for l, m in zip(labels, mask) if m]
242241

243242
def f1():
@@ -261,15 +260,12 @@ def get_line_transform(self, axes):
261260

262261
def get_line(self, axes):
263262
self.update_lim(axes)
264-
x, y = self.grid_info["line_xy"]
265-
266-
if self._get_line_path is None:
267-
return Path(np.column_stack([x, y]))
268-
else:
269-
return self._get_line_path(axes, x, y)
263+
x, y = self._grid_info["line_xy"]
264+
return Path(np.column_stack([x, y]))
270265

271266

272267
class GridHelperCurveLinear(GridHelperBase):
268+
grid_info = _api.deprecate_privatize_attribute("3.5")
273269

274270
def __init__(self, aux_trans,
275271
extreme_finder=None,
@@ -288,7 +284,7 @@ def __init__(self, aux_trans,
288284
e.g., ``x2, y2 = trans(x1, y1)``
289285
"""
290286
super().__init__()
291-
self.grid_info = None
287+
self._grid_info = None
292288
self._aux_trans = aux_trans
293289
self.grid_finder = GridFinder(aux_trans,
294290
extreme_finder,
@@ -347,15 +343,15 @@ def new_floating_axis(self, nth_coord,
347343
return axisline
348344

349345
def _update_grid(self, x1, y1, x2, y2):
350-
self.grid_info = self.grid_finder.get_grid_info(x1, y1, x2, y2)
346+
self._grid_info = self.grid_finder.get_grid_info(x1, y1, x2, y2)
351347

352348
def get_gridlines(self, which="major", axis="both"):
353349
grid_lines = []
354350
if axis in ["both", "x"]:
355-
for gl in self.grid_info["lon"]["lines"]:
351+
for gl in self._grid_info["lon"]["lines"]:
356352
grid_lines.extend(gl)
357353
if axis in ["both", "y"]:
358-
for gl in self.grid_info["lat"]["lines"]:
354+
for gl in self._grid_info["lat"]["lines"]:
359355
grid_lines.extend(gl)
360356
return grid_lines
361357

@@ -367,15 +363,15 @@ def get_tick_iterator(self, nth_coord, axis_side, minor=False):
367363
lon_or_lat = ["lon", "lat"][nth_coord]
368364
if not minor: # major ticks
369365
for (xy, a), l in zip(
370-
self.grid_info[lon_or_lat]["tick_locs"][axis_side],
371-
self.grid_info[lon_or_lat]["tick_labels"][axis_side]):
366+
self._grid_info[lon_or_lat]["tick_locs"][axis_side],
367+
self._grid_info[lon_or_lat]["tick_labels"][axis_side]):
372368
angle_normal = a
373369
yield xy, angle_normal, angle_tangent, l
374370
else:
375371
for (xy, a), l in zip(
376-
self.grid_info[lon_or_lat]["tick_locs"][axis_side],
377-
self.grid_info[lon_or_lat]["tick_labels"][axis_side]):
372+
self._grid_info[lon_or_lat]["tick_locs"][axis_side],
373+
self._grid_info[lon_or_lat]["tick_labels"][axis_side]):
378374
angle_normal = a
379375
yield xy, angle_normal, angle_tangent, ""
380-
# for xy, a, l in self.grid_info[lon_or_lat]["ticks"][axis_side]:
376+
# for xy, a, l in self._grid_info[lon_or_lat]["ticks"][axis_side]:
381377
# yield xy, a, ""

0 commit comments

Comments
 (0)