Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib axis label format

I am having an issue with the format of the tick labels of an axis. I disabled the offset from the y_axis:

ax1.ticklabel_format(style = 'sci', useOffset=False) 

and tried to put it a scientific format but all I get is:

0.00355872 

but I expected something like:

3.55872...E-2 

or similar.

what I really want is something like:

3.55872... (on the tick label) x 10^2  (or something similar - on the axis label) 

I could try to set the labels as static,, but in the end I will have a few tens or hundreds of plots with different values, so it needs to be set dynamically.

An alternative would be to place the y_axis offset as the label, but I also have no clue on how to do this.

like image 446
jorgehumberto Avatar asked Feb 08 '13 14:02

jorgehumberto


People also ask

How do you change the axis labels in Matplotlib?

To set labels on the x-axis and y-axis, use the plt. xlabel() and plt. ylabel() methods.

How do I use scientific notation in Matplotlib?

(m, n), pair of integers; if style is 'sci', scientific notation will be used for numbers outside the range 10m to 10n. Use (0,0) to include all numbers. Use (m,m) where m <> 0 to fix the order of magnitude to 10m.


1 Answers

You should also specify axis and threshold limits:

ax1.ticklabel_format(axis='y', style='sci', scilimits=(-2,2)) 

This would use sci format on y axis when figures are out of the [0.01, 99] bounds.

like image 74
Adobe Avatar answered Oct 08 '22 23:10

Adobe