@@ -541,21 +541,9 @@ def __init__(self, plot, parent=None):
541
541
# Set axis zorder=0.5 so grid is displayed at 0.5
542
542
self .ax .set_axisbelow (True )
543
543
544
- # disable the use of offsets
545
- try :
546
- axes = [
547
- self .ax .get_yaxis ().get_major_formatter (),
548
- self .ax .get_xaxis ().get_major_formatter (),
549
- self .ax2 .get_yaxis ().get_major_formatter (),
550
- self .ax2 .get_xaxis ().get_major_formatter (),
551
- ]
552
- for axis in axes :
553
- axis .set_useOffset (False )
554
- axis .set_scientific (False )
555
- except :
556
- _logger .warning (
557
- "Cannot disabled axes offsets in %s " % matplotlib .__version__
558
- )
544
+ # Configure axes tick label formatter
545
+ for axis in (self .ax .yaxis , self .ax .xaxis , self .ax2 .yaxis , self .ax2 .xaxis ):
546
+ self .__setAxisFormatter (axis )
559
547
560
548
self .ax2 .set_autoscaley_on (True )
561
549
@@ -575,6 +563,13 @@ def __init__(self, plot, parent=None):
575
563
self ._enableAxis ("right" , False )
576
564
self ._isXAxisTimeSeries = False
577
565
566
+ @staticmethod
567
+ def __setAxisFormatter (axis ):
568
+ """Configure matplotlib Axis formatter"""
569
+ formatter = ScalarFormatter (useOffset = True , useMathText = True )
570
+ formatter .set_scientific (True )
571
+ axis .set_major_formatter (formatter )
572
+
578
573
def getItemsFromBackToFront (self , condition = None ):
579
574
"""Order as BackendBase + take into account matplotlib Axes structure"""
580
575
@@ -1267,14 +1262,7 @@ def setXAxisTimeSeries(self, isTimeSeries):
1267
1262
NiceAutoDateFormatter (locator , tz = self .getXAxisTimeZone ())
1268
1263
)
1269
1264
else :
1270
- try :
1271
- scalarFormatter = ScalarFormatter (useOffset = False )
1272
- except :
1273
- _logger .warning (
1274
- "Cannot disabled axes offsets in %s " % matplotlib .__version__
1275
- )
1276
- scalarFormatter = ScalarFormatter ()
1277
- self .ax .xaxis .set_major_formatter (scalarFormatter )
1265
+ self .__setAxisFormatter (self .ax .xaxis )
1278
1266
1279
1267
def setXAxisLogarithmic (self , flag ):
1280
1268
# Workaround for matplotlib 2.1.0 when one tries to set an axis
0 commit comments