How To Remove Scientific Notation On A Matplotlib Log-log Plot
Solution 1:
Those are minor ticks on the x-axis (i.e. they are not on integer powers of 10), not major ticks. matplotlib
automatically detemines if it should label the major or minor ticks - in this case because you don't have any major ticks displayed in the x range, the minor ticks are being labelled). So, you need to use the set_minor_formatter
method:
ax.xaxis.set_minor_formatter(mticker.ScalarFormatter())
The reason it works on the y-axis is because those ticks are major ticks (i.e. on integer powers of 10), not minor ticks.
Solution 2:
The following can be used as a workaround (original answer):
from matplotlib.tickerimportStrMethodFormatter, NullFormatter
ax.yaxis.set_major_formatter(StrMethodFormatter('{x:.0f}'))
ax.yaxis.set_minor_formatter(NullFormatter())
Solution 3:
If you want to set just the xaxis to no longer use scientific notation you need to change the fromatter and then you can set it to plain.
ax.xaxis.set_minor_formatter(mticker.ScalarFormatter())
ax.ticklabel_format(style='plain', axis='x')
Solution 4:
If you want to disable both the offset and scientific notaion, you'd use ax.ticklabel_format(useOffset=False, style='plain')
Post a Comment for "How To Remove Scientific Notation On A Matplotlib Log-log Plot"