How to remove scientific notation on a matplotlib log-log plot How to remove scientific notation on a matplotlib log-log plot python python

How to remove scientific notation on a matplotlib log-log plot


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())

enter image description here

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.


The following can be used as a workaround (original answer):

from matplotlib.ticker import StrMethodFormatter, NullFormatterax.yaxis.set_major_formatter(StrMethodFormatter('{x:.0f}'))ax.yaxis.set_minor_formatter(NullFormatter())


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')