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')
Community
  • 1
  • 1
Argentina
  • 1,071
  • 5
  • 16
  • 30

1 Answers1

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)])
MB-F
  • 22,770
  • 4
  • 61
  • 116
  • I had thought of that, but it would be complicated, it is it is a multi-subplot figure.. – Argentina Feb 02 '15 at 08:42
  • 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? – MB-F Feb 02 '15 at 08:47