Skip to content Skip to sidebar Skip to footer

Scientific Tick Label Notation Tuning

I am not completely satisfied with the default scientific formatting for the tick labels. For example, import numpy as np import pylab pylab.rcParams['text.usetex'] = True pylab.t

Solution 1:

You can achieve it using the ScalarFormatter:

from matplotlib.ticker import ScalarFormatter

sf = ScalarFormatter()
sf.set_scientific(True)
sf.set_powerlimits((-0.00001, 0.00001))

ax = pylab.gca()
ax.yaxis.set_major_formatter(sf)
pylab.show()

You can test what the formatter will do to a given number by passing the number to format_data():

sf.format_data(0.002)#'2{\\times}10^{-3}'

Post a Comment for "Scientific Tick Label Notation Tuning"