0

I am plotting a histogram, taking the logarithm of the quantity before plotting, (instead of choosing a logarithmic scale for my plot) and in the tick labels on the x axis I obviously get the logarithm. I would like labels to show the scientific notation instead: in other words I would like 10^3 instead of 3, for example.

Is there any way to do that? I saw other questions, like Matplotlib - logarithmic scale, but require non-logarithmic labels, but this is not the same thing, I didn' use ax.set_xscale('log'). Here is a line of my code:

ax[0, 0].hist(np.log10(bh_100[:, 0]),bins=15, ls='dashed', color= 'b',   log=True, label = 'Bh-bh')

1 Answer 1

1

You can always use set_xticklabels to set the labels as you require them

For example, you can do:

ax.set_xticklabels(['10^{%d}'%i for i in range(5)])

or LaTeX-style:

ax.set_xticklabels(['$10^{%d}$'%i for i in range(5)])
Sign up to request clarification or add additional context in comments.

2 Comments

I had thought of that, but it would be complicated, it is it is a multi-subplot figure..
I don't know a built-in way to do what you want. What about writing your own function that loops over all subplots and changes the labels?

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.