168
168
long = int
169
169
170
170
171
+ def _mathdefault (s ):
172
+ """
173
+ For backward compatibility, in classic mode we display
174
+ sub/superscripted text in a mathdefault block. As of 2.0, the
175
+ math font already matches the default font, so we don't need to do
176
+ that anymore.
177
+ """
178
+ if rcParams ['_internal.classic_mode' ]:
179
+ return '\\ mathdefault{%s}' % s
180
+ else :
181
+ return '{%s}' % s
182
+
183
+
171
184
class _DummyAxis (object ):
172
185
def __init__ (self , minpos = 0 ):
173
186
self .dataLim = mtransforms .Bbox .unit ()
@@ -510,9 +523,8 @@ def get_offset(self):
510
523
sciNotStr = '1e%d' % self .orderOfMagnitude
511
524
if self ._useMathText :
512
525
if sciNotStr != '' :
513
- sciNotStr = r'\times\mathdefault{%s}' % sciNotStr
514
- s = '' .join (('$' , sciNotStr ,
515
- r'\mathdefault{' , offsetStr , '}$' ))
526
+ sciNotStr = r'\times%s' % _mathdefault (sciNotStr )
527
+ s = '' .join (('$' , sciNotStr , _mathdefault (offsetStr ), '$' ))
516
528
elif self ._usetex :
517
529
if sciNotStr != '' :
518
530
sciNotStr = r'\times%s' % sciNotStr
@@ -613,7 +625,7 @@ def _set_format(self, vmin, vmax):
613
625
if self ._usetex :
614
626
self .format = '$%s$' % self .format
615
627
elif self ._useMathText :
616
- self .format = '$\mathdefault{%s} $' % self .format
628
+ self .format = '$%s $' % _mathdefault ( self .format )
617
629
618
630
def pprint_val (self , x ):
619
631
xp = (x - self .offset ) / (10. ** self .orderOfMagnitude )
@@ -790,7 +802,7 @@ def __call__(self, x, pos=None):
790
802
if usetex :
791
803
return '$0$'
792
804
else :
793
- return '$\mathdefault{0}$'
805
+ return '$%s$' % _mathdefault ( '0' )
794
806
795
807
fx = math .log (abs (x )) / math .log (b )
796
808
is_decade = is_close_to_int (fx )
@@ -810,17 +822,18 @@ def __call__(self, x, pos=None):
810
822
return (r'$%s%s^{%.2f}$' ) % \
811
823
(sign_string , base , fx )
812
824
else :
813
- return ('$\mathdefault{%s%s^{%.2f}}$' ) % \
814
- (sign_string , base , fx )
825
+ return ('$%s$' % _mathdefault (
826
+ '%s%s^{%.2f}' %
827
+ (sign_string , base , fx )))
815
828
else :
816
829
if usetex :
817
830
return (r'$%s%s^{%d}$' ) % (sign_string ,
818
831
base ,
819
832
nearest_long (fx ))
820
833
else :
821
- return (r'$\mathdefault{%s%s^{%d}}$' ) % ( sign_string ,
822
- base ,
823
- nearest_long (fx ))
834
+ return ('$%s$' % _mathdefault (
835
+ '%s%s^{%d}' %
836
+ ( sign_string , base , nearest_long (fx )) ))
824
837
825
838
826
839
class LogitFormatter (Formatter ):
0 commit comments