@@ -541,21 +541,9 @@ def __init__(self, plot, parent=None):
541541 # Set axis zorder=0.5 so grid is displayed at 0.5
542542 self .ax .set_axisbelow (True )
543543
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 )
559547
560548 self .ax2 .set_autoscaley_on (True )
561549
@@ -575,6 +563,13 @@ def __init__(self, plot, parent=None):
575563 self ._enableAxis ("right" , False )
576564 self ._isXAxisTimeSeries = False
577565
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+
578573 def getItemsFromBackToFront (self , condition = None ):
579574 """Order as BackendBase + take into account matplotlib Axes structure"""
580575
@@ -1267,14 +1262,7 @@ def setXAxisTimeSeries(self, isTimeSeries):
12671262 NiceAutoDateFormatter (locator , tz = self .getXAxisTimeZone ())
12681263 )
12691264 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 )
12781266
12791267 def setXAxisLogarithmic (self , flag ):
12801268 # Workaround for matplotlib 2.1.0 when one tries to set an axis
0 commit comments