matplotlib: ylabel on the right

To make a ylabel on the right, use the text command. You need to set
the transform to use axes coordinates (ax.transAxes), rotate the text
vertically, make the horizontal alignment left, the vertical alignment
centered. Note that x, y = 1, 0.5 is the right, middle of the axes in
axes coordinates. You also need to turn off clipping, so the text can
appear outside the axes w/o being clipped by the axes bounding box,
which is the default behavior.

from pylab import *

plot([1,2,3])

text(1.02, 0.5, 'volts',
horizontalalignment='left',
verticalalignment='center',
rotation='vertical',
transform=gca().transAxes,
clip_on=False)
show()
posted @ 2009-04-23 09:51  owomo  阅读(620)  评论(0编辑  收藏  举报