Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib.pyplot: force exponential axis label notation [duplicate]

In a plot created by matplotlib.pyplot, how can I force the axis labels to be shown in exponential notation? This seems to be done automatically for values < 1e-6, but for, say, 5e-6 I get "0.000005". I'd prefer to have it shown as "5e-6" also for this range.

like image 980
gandi2223 Avatar asked Jul 24 '13 23:07

gandi2223


1 Answers

It seems like you should be able to set the power limits of the ScalarFormatter for the axes. (untested code)

# Set limits to x < 10^1 and x > 10^-1 
# (overlapping, thus all inclusive, hopefully)
gca().get_yaxis().get_major_formatter().set_powerlimits((0, 0))
like image 142
voithos Avatar answered Sep 28 '22 19:09

voithos