How to change the font size of scientific notation in matplotlib?

I want to make a plot with a large font size, I can easily change all font sizes, except when I use scientific notation in the axis label. I searched and tried, but did not find a way to resize the scientific application. See this picture:

http://i.imgur.com/Rtv9hw6.png1

In this figure, “1e-4” is too small compared to other texts and labels. These codes are related to creating the extended fonts used in this figure:

ax.tick_params(labelsize=24)
ax.yaxis.get_major_formatter().set_powerlimits((0, 1))
ax.text(0.3,4.9e-4,'(a)',va='top',fontsize=24)
plt.xlabel('$r$ (a.u.)',fontsize=24)
plt.ylabel('Probability',fontsize=24)

By the way, how to change "1e-4" to "x1e-4"? Thanks!

+4
source share
2 answers

You want to resize offset_textfrom yaxis. You can do this with this line:

ax.yaxis.get_offset_text().set_fontsize(24)

Or equivalently:

ax.yaxis.offsetText.set_fontsize(24)

enter image description here

+6

ax.yaxis.set_major_formatter (ScalarFormatter (useOffset = True, useMathText = True))

0

Source: https://habr.com/ru/post/1619528/


All Articles