How To Turn On Scientific Notation In Matplotilb Bar Chart?
I am trying to turn on scientific notation in this plot so that the numbers on the y-axis don't take up so much space. Currently my code is: import matplotlib.pyplot as plt import
Solution 1:
You can add these 3 lines before plt.show()
:
mf = mpl.ticker.ScalarFormatter(useMathText=True)
mf.set_powerlimits((-2,2))
plt.gca().yaxis.set_major_formatter(mf)
Check also this link for set_powerlimits()
Post a Comment for "How To Turn On Scientific Notation In Matplotilb Bar Chart?"