3232
3333docstring .snippets ['formatter.params' ] = """
3434zerotrim : bool, optional
35- Whether to trim trailing zeros. Default is :rc:`axes. formatter.zerotrim`.
35+ Whether to trim trailing zeros. Default is :rc:`formatter.zerotrim`.
3636tickrange : (float, float), optional
3737 Range within which major tick marks are labelled. Default is ``(-np.inf, np.inf)``.
3838wraprange : (float, float), optional
4747"""
4848
4949
50- class _GeoFormatter (object ):
51- """
52- Mixin class that fixes cartopy formatters.
53- """
54- # NOTE: Cartopy formatters pre 0.18 required axis, and *always* translated
55- # input values from map projection coordinates to Plate Carrée coordinates.
56- # After 0.18 you can avoid this behavior by not setting axis but really
57- # dislike that inconsistency. Solution is temporarily change projection.
58- def __init__ (self , * args , ** kwargs ):
59- import cartopy # noqa: F401 (ensure available)
60- super ().__init__ (* args , ** kwargs )
61-
62- def __call__ (self , value , pos = None ):
63- if self .axis is not None :
64- context = _set_state (self .axis .axes , projection = ccrs .PlateCarree ())
65- else :
66- context = _dummy_context ()
67- with context :
68- return super ().__call__ (value , pos )
69-
70-
71- class _LongitudeFormatter (_GeoFormatter , LongitudeFormatter ):
72- """
73- Mix longitude formatter with custom formatter.
74- """
75- pass
76-
77-
78- class _LatitudeFormatter (_GeoFormatter , LatitudeFormatter ):
79- """
80- Mix latitude formatter with custom formatter.
81- """
82- pass
83-
84-
8550class _GeoLocator (mticker .MaxNLocator ):
8651 """
8752 A locator for determining longitude and latitude gridlines.
@@ -169,6 +134,41 @@ def _raw_ticks(self, vmin, vmax):
169134 return [t for t in ticks if - 90 <= t <= 90 ]
170135
171136
137+ class _GeoFormatter (object ):
138+ """
139+ Mixin class that fixes cartopy formatters.
140+ """
141+ # NOTE: Cartopy formatters pre 0.18 required axis, and *always* translated
142+ # input values from map projection coordinates to Plate Carrée coordinates.
143+ # After 0.18 you can avoid this behavior by not setting axis but really
144+ # dislike that inconsistency. Solution is temporarily change projection.
145+ def __init__ (self , * args , ** kwargs ):
146+ import cartopy # noqa: F401 (ensure available)
147+ super ().__init__ (* args , ** kwargs )
148+
149+ def __call__ (self , value , pos = None ):
150+ if self .axis is not None :
151+ context = _set_state (self .axis .axes , projection = ccrs .PlateCarree ())
152+ else :
153+ context = _dummy_context ()
154+ with context :
155+ return super ().__call__ (value , pos )
156+
157+
158+ class _LongitudeFormatter (_GeoFormatter , LongitudeFormatter ):
159+ """
160+ Mix longitude formatter with custom formatter.
161+ """
162+ pass
163+
164+
165+ class _LatitudeFormatter (_GeoFormatter , LatitudeFormatter ):
166+ """
167+ Mix latitude formatter with custom formatter.
168+ """
169+ pass
170+
171+
172172class AutoFormatter (mticker .ScalarFormatter ):
173173 """
174174 The new default formatter. Differs from `~matplotlib.ticker.ScalarFormatter`
@@ -207,7 +207,7 @@ def __init__(
207207 tickrange = tickrange or (- np .inf , np .inf )
208208 super ().__init__ (** kwargs )
209209 from .config import rc
210- zerotrim = _not_none (zerotrim , rc ['axes. formatter.zerotrim' ])
210+ zerotrim = _not_none (zerotrim , rc ['formatter.zerotrim' ])
211211 self ._zerotrim = zerotrim
212212 self ._tickrange = tickrange
213213 self ._wraprange = wraprange
@@ -307,7 +307,7 @@ def _get_decimal_point(self, use_locale=None):
307307 """
308308 from .config import rc
309309 use_locale = _not_none (
310- use_locale , self .get_useLocale (), rc ['axes. formatter.use_locale' ]
310+ use_locale , self .get_useLocale (), rc ['formatter.use_locale' ]
311311 )
312312 return locale .localeconv ()['decimal_point' ] if use_locale else '.'
313313
@@ -317,7 +317,7 @@ def _get_default_decimal_point(use_locale=None):
317317 Get decimal point symbol for current locale. Called externally.
318318 """
319319 from .config import rc
320- use_locale = _not_none (use_locale , rc ['axes. formatter.use_locale' ])
320+ use_locale = _not_none (use_locale , rc ['formatter.use_locale' ])
321321 return locale .localeconv ()['decimal_point' ] if use_locale else '.'
322322
323323 @staticmethod
@@ -397,7 +397,7 @@ def SigFigFormatter(sigfig=1, zerotrim=None):
397397 Whether to trim trailing zeros.
398398 """
399399 from .config import rc
400- zerotrim = _not_none (zerotrim , rc ['axes. formatter.zerotrim' ])
400+ zerotrim = _not_none (zerotrim , rc ['formatter.zerotrim' ])
401401
402402 def func (x , pos ):
403403 # Limit digits to significant figures
@@ -438,7 +438,7 @@ def SimpleFormatter(
438438 %(formatter.params)s
439439 """
440440 from .config import rc
441- zerotrim = _not_none (zerotrim , rc ['axes. formatter.zerotrim' ])
441+ zerotrim = _not_none (zerotrim , rc ['formatter.zerotrim' ])
442442 tickrange = tickrange or (- np .inf , np .inf )
443443 prefix = prefix or ''
444444 suffix = suffix or ''
0 commit comments