188
188
'SymmetricalLogLocator' , 'LogitLocator' , 'OldAutoLocator' )
189
189
190
190
191
- def _mathdefault (s ):
192
- return '\\ mathdefault{%s}' % s
193
-
194
-
195
191
class _DummyAxis :
196
192
def __init__ (self , minpos = 0 ):
197
193
self .dataLim = mtransforms .Bbox .unit ()
@@ -654,14 +650,10 @@ def get_offset(self):
654
650
sciNotStr = self .format_data (10 ** self .orderOfMagnitude )
655
651
else :
656
652
sciNotStr = '1e%d' % self .orderOfMagnitude
657
- if self ._useMathText :
658
- if sciNotStr != '' :
659
- sciNotStr = r'\times%s' % _mathdefault (sciNotStr )
660
- s = '' .join (('$' , sciNotStr , _mathdefault (offsetStr ), '$' ))
661
- elif self ._usetex :
653
+ if self ._useMathText or self ._usetex :
662
654
if sciNotStr != '' :
663
- sciNotStr = r'\times%s ' % sciNotStr
664
- s = '' . join (( '$' , sciNotStr , offsetStr , '$' ) )
655
+ sciNotStr = r'\times\mathdefault{%s} ' % sciNotStr
656
+ s = r'$%s\mathdefault{%s}$' % ( sciNotStr , offsetStr )
665
657
else :
666
658
s = '' .join ((sciNotStr , offsetStr ))
667
659
@@ -784,10 +776,8 @@ def _set_format(self):
784
776
break
785
777
sigfigs += 1
786
778
self .format = '%1.' + str (sigfigs ) + 'f'
787
- if self ._usetex :
788
- self .format = '$%s$' % self .format
789
- elif self ._useMathText :
790
- self .format = '$%s$' % _mathdefault (self .format )
779
+ if self ._usetex or self ._useMathText :
780
+ self .format = r'$\mathdefault{%s}$' % self .format
791
781
792
782
@cbook .deprecated ("3.1" )
793
783
def pprint_val (self , x ):
@@ -1079,11 +1069,7 @@ class LogFormatterMathtext(LogFormatter):
1079
1069
1080
1070
def _non_decade_format (self , sign_string , base , fx , usetex ):
1081
1071
'Return string for non-decade locations'
1082
- if usetex :
1083
- return (r'$%s%s^{%.2f}$' ) % (sign_string , base , fx )
1084
- else :
1085
- return ('$%s$' % _mathdefault ('%s%s^{%.2f}' %
1086
- (sign_string , base , fx )))
1072
+ return r'$\mathdefault{%s%s^{%.2f}}$' % (sign_string , base , fx )
1087
1073
1088
1074
def __call__ (self , x , pos = None ):
1089
1075
"""
@@ -1095,10 +1081,7 @@ def __call__(self, x, pos=None):
1095
1081
min_exp = rcParams ['axes.formatter.min_exponent' ]
1096
1082
1097
1083
if x == 0 : # Symlog
1098
- if usetex :
1099
- return '$0$'
1100
- else :
1101
- return '$%s$' % _mathdefault ('0' )
1084
+ return r'$\mathdefault{0}$'
1102
1085
1103
1086
sign_string = '-' if x < 0 else ''
1104
1087
x = abs (x )
@@ -1124,17 +1107,11 @@ def __call__(self, x, pos=None):
1124
1107
base = '%s' % b
1125
1108
1126
1109
if np .abs (fx ) < min_exp :
1127
- if usetex :
1128
- return r'${0}{1:g}$' .format (sign_string , x )
1129
- else :
1130
- return '${0}$' .format (_mathdefault (
1131
- '{0}{1:g}' .format (sign_string , x )))
1110
+ return r'$\mathdefault{%s%g}$' % (sign_string , x )
1132
1111
elif not is_x_decade :
1133
1112
return self ._non_decade_format (sign_string , base , fx , usetex )
1134
- elif usetex :
1135
- return r'$%s%s^{%d}$' % (sign_string , base , fx )
1136
1113
else :
1137
- return '$%s$' % _mathdefault ( '%s%s ^{%d}' % (sign_string , base , fx ) )
1114
+ return r'$\mathdefault{%s%s ^{%d}}$ ' % (sign_string , base , fx )
1138
1115
1139
1116
1140
1117
class LogFormatterSciNotation (LogFormatterMathtext ):
@@ -1149,12 +1126,8 @@ def _non_decade_format(self, sign_string, base, fx, usetex):
1149
1126
coeff = b ** fx / b ** exponent
1150
1127
if is_close_to_int (coeff ):
1151
1128
coeff = round (coeff )
1152
- if usetex :
1153
- return (r'$%s%g\times%s^{%d}$' ) % \
1154
- (sign_string , coeff , base , exponent )
1155
- else :
1156
- return ('$%s$' % _mathdefault (r'%s%g\times%s^{%d}' %
1157
- (sign_string , coeff , base , exponent )))
1129
+ return r'$\mathdefault{%s%g\times%s^{%d}}$' \
1130
+ % (sign_string , coeff , base , exponent )
1158
1131
1159
1132
1160
1133
class LogitFormatter (Formatter ):
@@ -1326,8 +1299,6 @@ def __call__(self, x, pos=None):
1326
1299
return ""
1327
1300
if x <= 0 or x >= 1 :
1328
1301
return ""
1329
- usetex = rcParams ["text.usetex" ]
1330
-
1331
1302
if is_close_to_int (2 * x ) and round (2 * x ) == 1 :
1332
1303
s = self ._one_half
1333
1304
elif x < 0.5 and is_decade (x , rtol = 1e-7 ):
@@ -1342,9 +1313,7 @@ def __call__(self, x, pos=None):
1342
1313
s = self ._one_minus (self ._format_value (1 - x , 1 - self .locs ))
1343
1314
else :
1344
1315
s = self ._format_value (x , self .locs , sci_notation = False )
1345
- if usetex :
1346
- return "$%s$" % s
1347
- return "$%s$" % _mathdefault (s )
1316
+ return r"$\mathdefault{%s}$" % s
1348
1317
1349
1318
def format_data_short (self , value ):
1350
1319
"""
0 commit comments