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