1
1
import numpy as np
2
2
3
- import matplotlib . ticker as mticker
3
+ from matplotlib import cbook , ticker as mticker
4
4
from matplotlib .transforms import Bbox , Transform
5
5
from .clip_path import clip_line_to_rect
6
6
@@ -40,26 +40,38 @@ def _add_pad(self, lon_min, lon_max, lat_min, lat_max):
40
40
return lon_min , lon_max , lat_min , lat_max
41
41
42
42
43
- class GridFinderBase ( object ) :
43
+ class GridFinder :
44
44
def __init__ (self ,
45
- extreme_finder ,
46
- grid_locator1 ,
47
- grid_locator2 ,
45
+ transform ,
46
+ extreme_finder = None ,
47
+ grid_locator1 = None ,
48
+ grid_locator2 = None ,
48
49
tick_formatter1 = None ,
49
50
tick_formatter2 = None ):
50
51
"""
52
+ transform : transform from the image coordinate (which will be
51
53
the transData of the axes to the world coordinate.
52
- locator1, locator2 : grid locator for 1st and 2nd axis.
53
54
54
- Derived must define "transform_xy, inv_transform_xy"
55
- (may use update_transform)
55
+ or transform = (transform_xy, inv_transform_xy)
56
+
57
+ locator1, locator2 : grid locator for 1st and 2nd axis.
56
58
"""
57
- super ().__init__ ()
59
+ if extreme_finder is None :
60
+ extreme_finder = ExtremeFinderSimple (20 , 20 )
61
+ if grid_locator1 is None :
62
+ grid_locator1 = MaxNLocator ()
63
+ if grid_locator2 is None :
64
+ grid_locator2 = MaxNLocator ()
65
+ if tick_formatter1 is None :
66
+ tick_formatter1 = FormatterPrettyPrint ()
67
+ if tick_formatter2 is None :
68
+ tick_formatter2 = FormatterPrettyPrint ()
58
69
self .extreme_finder = extreme_finder
59
70
self .grid_locator1 = grid_locator1
60
71
self .grid_locator2 = grid_locator2
61
72
self .tick_formatter1 = tick_formatter1
62
73
self .tick_formatter2 = tick_formatter2
74
+ self .update_transform (transform )
63
75
64
76
def get_grid_info (self , x1 , y1 , x2 , y2 ):
65
77
"""
@@ -190,40 +202,17 @@ def update(self, **kw):
190
202
raise ValueError ("unknown update property '%s'" % k )
191
203
192
204
193
- class GridFinder ( GridFinderBase ):
194
-
205
+ @ cbook . deprecated ( "3.2" )
206
+ class GridFinderBase ( GridFinder ):
195
207
def __init__ (self ,
196
- transform ,
197
- extreme_finder = None ,
208
+ extreme_finder ,
198
209
grid_locator1 = None ,
199
210
grid_locator2 = None ,
200
211
tick_formatter1 = None ,
201
212
tick_formatter2 = None ):
202
- """
203
- transform : transform from the image coordinate (which will be
204
- the transData of the axes to the world coordinate.
205
-
206
- or transform = (transform_xy, inv_transform_xy)
207
-
208
- locator1, locator2 : grid locator for 1st and 2nd axis.
209
- """
210
- if extreme_finder is None :
211
- extreme_finder = ExtremeFinderSimple (20 , 20 )
212
- if grid_locator1 is None :
213
- grid_locator1 = MaxNLocator ()
214
- if grid_locator2 is None :
215
- grid_locator2 = MaxNLocator ()
216
- if tick_formatter1 is None :
217
- tick_formatter1 = FormatterPrettyPrint ()
218
- if tick_formatter2 is None :
219
- tick_formatter2 = FormatterPrettyPrint ()
220
- super ().__init__ (
221
- extreme_finder ,
222
- grid_locator1 ,
223
- grid_locator2 ,
224
- tick_formatter1 ,
225
- tick_formatter2 )
226
- self .update_transform (transform )
213
+ super ().__init__ ((None , None ), extreme_finder ,
214
+ grid_locator1 , grid_locator2 ,
215
+ tick_formatter1 , tick_formatter2 )
227
216
228
217
229
218
class MaxNLocator (mticker .MaxNLocator ):
0 commit comments