Hello,
I'm having some trouble figuring out how to format the numerical labels on the tick marks of an axes. For example, in the plot linked below, I'd like the y-axis to display using scientific notation, and I'd like to control the precision level. I feel like this should be somehow possible using setp(yticklabels,...) but I haven't been able to find the relevant documentation or an example. Can someone point me in the right direction here?
Also, if someone has a suggestion for how to automatically avoid the axis label ('CW') being cut off like in the attachment, let me know (I'm letting the figure size get set automatically).
Please feel free to point me to a relevant section of the manual or to a function that I might be missing.
Thank you,
--Jordan
Here is the example: http://www.people.cornell.edu/pages/jca33/labels.pdf
Hello,
I'm having some trouble figuring out how to format the numerical
labels on the tick marks of an axes. For example, in the plot linked
below, I'd like the y-axis to display using scientific notation, and I'd
like to control the precision level. I feel like this should be somehow
possible using setp(yticklabels,...) but I haven't been able to find the
relevant documentation or an example. Can someone point me in the right
direction here?
You can set the formatter for the yaxis
from matplotlib.ticker import FormatStrFormatter
fmt = FormatStrFormatter('%1.4g') # or whatever
ax.yaxis.set_major_formatter(fmt)
There is also a class tickers.ScalarFormatter for scientific
formatting that is customizable. You'll probably want to take a look
at it.
Also, if someone has a suggestion for how to automatically avoid the
axis label ('CW') being cut off like in the attachment, let me know (I'm
letting the figure size get set automatically).
The easiest way to fix this is just to move the left border of your
axes over a bit
fig = figure()
fig.subplots_adjust(left=0.2)
ax = fig.add_subplot(111) # now there is more space on the left
JDH
···
On 10/18/07, Jordan Atlas <[email protected]...> wrote: