Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

python - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...