@@ -280,21 +280,23 @@ def get_offset(self):
280
280
def set_locs (self , locs ):
281
281
self .locs = locs
282
282
283
- def fix_minus (self , s ):
284
- """
285
- Some classes may want to replace a hyphen for minus with the
286
- proper unicode symbol (U+2212) for typographical correctness.
287
- The default is to not replace it.
288
-
289
- Note, if you use this method, e.g., in :meth:`format_data` or
290
- call, you probably don't want to use it for
291
- :meth:`format_data_short` since the toolbar uses this for
292
- interactive coord reporting and I doubt we can expect GUIs
293
- across platforms will handle the unicode correctly. So for
294
- now the classes that override :meth:`fix_minus` should have an
295
- explicit :meth:`format_data_short` method
296
- """
297
- return s
283
+ @staticmethod
284
+ def fix_minus (s ):
285
+ """
286
+ Some classes may want to replace a hyphen for minus with the proper
287
+ unicode symbol (U+2212) for typographical correctness. This is a
288
+ helper method to perform such a replacement when it is enabled via
289
+ :rc:`axes.unicode_minus`.
290
+ """
291
+ # Additionally, we disable the replacement when using usetex without
292
+ # unicode support (this is deprecated, i.e., in a future version,
293
+ # unicode support will always be enabled).
294
+ if (rcParams ['axes.unicode_minus' ]
295
+ and (rcParams ['text.latex.unicode' ]
296
+ or not rcParams ['text.usetex' ])):
297
+ return s .replace ('-' , '\N{MINUS SIGN} ' )
298
+ else :
299
+ return s
298
300
299
301
def _set_locator (self , locator ):
300
302
"""Subclasses may want to override this to set a locator."""
@@ -565,15 +567,6 @@ def set_useMathText(self, val):
565
567
566
568
useMathText = property (fget = get_useMathText , fset = set_useMathText )
567
569
568
- def fix_minus (self , s ):
569
- """
570
- Replace hyphens with a unicode minus.
571
- """
572
- if rcParams ['text.usetex' ] or not rcParams ['axes.unicode_minus' ]:
573
- return s
574
- else :
575
- return s .replace ('-' , '\N{MINUS SIGN} ' )
576
-
577
570
def __call__ (self , x , pos = None ):
578
571
"""
579
572
Return the format for tick value *x* at position *pos*.
@@ -624,15 +617,12 @@ def set_powerlimits(self, lims):
624
617
self ._powerlimits = lims
625
618
626
619
def format_data_short (self , value ):
627
- """
628
- Return a short formatted string representation of a number.
629
- """
630
- if self ._useLocale :
631
- return locale .format_string ('%-12g' , (value ,))
632
- elif isinstance (value , np .ma .MaskedArray ) and value .mask :
633
- return ''
634
- else :
635
- return '%-12g' % value
620
+ # docstring inherited
621
+ return (
622
+ "" if isinstance (value , np .ma .MaskedArray ) and value .mask else
623
+ self .fix_minus (
624
+ locale .format_string ("%-12g" , (value ,)) if self ._useLocale else
625
+ "%-12g" % value ))
636
626
637
627
def format_data (self , value ):
638
628
"""
@@ -1026,7 +1016,7 @@ def __call__(self, x, pos=None):
1026
1016
vmin , vmax = self .axis .get_view_interval ()
1027
1017
vmin , vmax = mtransforms .nonsingular (vmin , vmax , expander = 0.05 )
1028
1018
s = self ._num_to_string (x , vmin , vmax )
1029
- return self . fix_minus ( s )
1019
+ return s
1030
1020
1031
1021
def format_data (self , value ):
1032
1022
b = self .labelOnlyBase
@@ -1036,9 +1026,7 @@ def format_data(self, value):
1036
1026
return value
1037
1027
1038
1028
def format_data_short (self , value ):
1039
- """
1040
- Return a short formatted string representation of a number.
1041
- """
1029
+ # docstring inherited
1042
1030
return '%-12g' % value
1043
1031
1044
1032
@cbook .deprecated ("3.1" )
@@ -1462,12 +1450,6 @@ def set_useMathText(self, val):
1462
1450
1463
1451
useMathText = property (fget = get_useMathText , fset = set_useMathText )
1464
1452
1465
- def fix_minus (self , s ):
1466
- """
1467
- Replace hyphens with a unicode minus.
1468
- """
1469
- return ScalarFormatter .fix_minus (self , s )
1470
-
1471
1453
def __call__ (self , x , pos = None ):
1472
1454
s = "%s%s" % (self .format_eng (x ), self .unit )
1473
1455
# Remove the trailing separator when there is neither prefix nor unit
0 commit comments