I am plotting an inset into a bigger figure and I have a problem with resizing the ticks for both axes for the inset.
I have looked at this question Matplotlib make tick labels font size smaller and managed to resize ticks.
However, my ticks are plotted using scientific notation on both axes (automatically) and while that is not a problem the '1e-7' label doesn't resize with the rest of the ticks and it superimposes with the x axis label.
Can someone tell me how to change the size of the '1e-7'? I can't find a way!
Here is the code and the figure that is causing me problems.
logN = lognorm(s=[sigma], loc=0, scale=exp(mu))
domain = np.linspace(logN.ppf(0.01), logN.ppf(0.99), 250)
ax2.set_title('uncertainty', size = 'x-small')
ax2.set_xlabel('exceedance frequency', size = 'x-small')
ax2.set_ylabel('probability', size= 'x-small')
ax2.tick_params( axis = 'both', which ='major', labelsize = 7)
ax2.plot(domain, logN.pdf(domain))
One way is to use the ax.yaxis.get_offset_text()
method to return the text object and then set it with set_fontsize(7)
. Try:
tx = ax2.xaxis.get_offset_text()
tx.set_fontsize(7)
Alternatively, if you'd like to remove the offsets and then add them at a position of your choice, then use:
tx.set_visible(False)
ax2.text(1.1, -.1, "1e-7", fontsize=7)
You may have to fiddle with the x and y positions manually until it looks good.