5
5
6
6
import numpy as np
7
7
8
+ from matplotlib import _api
8
9
from matplotlib .path import Path
9
10
from matplotlib .transforms import Affine2D , IdentityTransform
10
11
from .axislines import AxisArtistHelper , GridHelperBase
@@ -75,19 +76,17 @@ def get_tick_iterators(self, axes):
75
76
76
77
77
78
class FloatingAxisArtistHelper (AxisArtistHelper .Floating ):
79
+ grid_info = _api .deprecate_privatize_attribute ("3.5" )
78
80
79
81
def __init__ (self , grid_helper , nth_coord , value , axis_direction = None ):
80
82
"""
81
83
nth_coord = along which coordinate value varies.
82
84
nth_coord = 0 -> x axis, nth_coord = 1 -> y axis
83
85
"""
84
-
85
86
super ().__init__ (nth_coord , value )
86
87
self .value = value
87
88
self .grid_helper = grid_helper
88
89
self ._extremes = - np .inf , np .inf
89
-
90
- self ._get_line_path = None # a method that returns a Path.
91
90
self ._line_num_points = 100 # number of points to create a line
92
91
93
92
def set_extremes (self , e1 , e2 ):
@@ -129,7 +128,7 @@ def update_lim(self, axes):
129
128
yy0 = np .full (self ._line_num_points , self .value )
130
129
xx , yy = grid_finder .transform_xy (xx0 , yy0 )
131
130
132
- self .grid_info = {
131
+ self ._grid_info = {
133
132
"extremes" : (lon_min , lon_max , lat_min , lat_max ),
134
133
"lon_info" : (lon_levs , lon_n , lon_factor ),
135
134
"lat_info" : (lat_levs , lat_n , lat_factor ),
@@ -145,7 +144,7 @@ def get_axislabel_transform(self, axes):
145
144
146
145
def get_axislabel_pos_angle (self , axes ):
147
146
148
- extremes = self .grid_info ["extremes" ]
147
+ extremes = self ._grid_info ["extremes" ]
149
148
150
149
if self .nth_coord == 0 :
151
150
xx0 = self .value
@@ -180,12 +179,12 @@ def get_tick_iterators(self, axes):
180
179
181
180
grid_finder = self .grid_helper .grid_finder
182
181
183
- lat_levs , lat_n , lat_factor = self .grid_info ["lat_info" ]
182
+ lat_levs , lat_n , lat_factor = self ._grid_info ["lat_info" ]
184
183
lat_levs = np .asarray (lat_levs )
185
184
yy0 = lat_levs / lat_factor
186
185
dy = 0.01 / lat_factor
187
186
188
- lon_levs , lon_n , lon_factor = self .grid_info ["lon_info" ]
187
+ lon_levs , lon_n , lon_factor = self ._grid_info ["lon_info" ]
189
188
lon_levs = np .asarray (lon_levs )
190
189
xx0 = lon_levs / lon_factor
191
190
dx = 0.01 / lon_factor
@@ -221,7 +220,7 @@ def transform_xy(x, y):
221
220
xx2a , yy2a = transform_xy (xx0 , yy0 )
222
221
xx2b , yy2b = transform_xy (xx0 , yy0 + dy )
223
222
224
- labels = self .grid_info ["lat_labels" ]
223
+ labels = self ._grid_info ["lat_labels" ]
225
224
labels = [l for l , m in zip (labels , mask ) if m ]
226
225
227
226
elif self .nth_coord == 1 :
@@ -237,7 +236,7 @@ def transform_xy(x, y):
237
236
xx2a , yy2a = transform_xy (xx00 , yy0 )
238
237
xx2b , yy2b = transform_xy (xx00 + dx , yy0 )
239
238
240
- labels = self .grid_info ["lon_labels" ]
239
+ labels = self ._grid_info ["lon_labels" ]
241
240
labels = [l for l , m in zip (labels , mask ) if m ]
242
241
243
242
def f1 ():
@@ -261,15 +260,12 @@ def get_line_transform(self, axes):
261
260
262
261
def get_line (self , axes ):
263
262
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 ]))
270
265
271
266
272
267
class GridHelperCurveLinear (GridHelperBase ):
268
+ grid_info = _api .deprecate_privatize_attribute ("3.5" )
273
269
274
270
def __init__ (self , aux_trans ,
275
271
extreme_finder = None ,
@@ -288,7 +284,7 @@ def __init__(self, aux_trans,
288
284
e.g., ``x2, y2 = trans(x1, y1)``
289
285
"""
290
286
super ().__init__ ()
291
- self .grid_info = None
287
+ self ._grid_info = None
292
288
self ._aux_trans = aux_trans
293
289
self .grid_finder = GridFinder (aux_trans ,
294
290
extreme_finder ,
@@ -347,15 +343,15 @@ def new_floating_axis(self, nth_coord,
347
343
return axisline
348
344
349
345
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 )
351
347
352
348
def get_gridlines (self , which = "major" , axis = "both" ):
353
349
grid_lines = []
354
350
if axis in ["both" , "x" ]:
355
- for gl in self .grid_info ["lon" ]["lines" ]:
351
+ for gl in self ._grid_info ["lon" ]["lines" ]:
356
352
grid_lines .extend (gl )
357
353
if axis in ["both" , "y" ]:
358
- for gl in self .grid_info ["lat" ]["lines" ]:
354
+ for gl in self ._grid_info ["lat" ]["lines" ]:
359
355
grid_lines .extend (gl )
360
356
return grid_lines
361
357
@@ -367,15 +363,15 @@ def get_tick_iterator(self, nth_coord, axis_side, minor=False):
367
363
lon_or_lat = ["lon" , "lat" ][nth_coord ]
368
364
if not minor : # major ticks
369
365
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 ]):
372
368
angle_normal = a
373
369
yield xy , angle_normal , angle_tangent , l
374
370
else :
375
371
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 ]):
378
374
angle_normal = a
379
375
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]:
381
377
# yield xy, a, ""
0 commit comments