32

I want to make a plot with large font size, I can change all font sizes easily except when I use scientific notations in the axis label. I have searched and tried but haven't found a way to change the size of the scientific appendix. See this figure:

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

In this figure, "1e-4" is just too small compared to other texts and labels. These codes are relevant in producing the enlarged 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" into "x1e-4"? Thanks!

2 Answers 2

49

You want to change the fontsize of the offset_text from the yaxis. You can do that with this line:

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

Or equivalently:

ax.yaxis.offsetText.set_fontsize(24)

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot! BTW, how to change "1e-4" into "x1e-4"?
not sure about that, sorry. You might want to ask a new question, hopefully someone who knows will see it. If you set the text.usetex rcParams to True, I think it changes to x10^-4, if that's any help to you.
If you mostly use matplotlib commands using plt then do plt.gca().yaxis.get_offset_text().set_fontsize(24)
5

I use ax.yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) for changing 1e-4 to x10^-4

1 Comment

One small remark: call set_major_formatter before ticklabel_format, otherwise it may revert the ticks back to decimal notation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.