making horizontal axes labels in plots

hi all,

i am trying to make horizontal (as opposed to the default vertical)
rotated labels for axes in my subplots. i tried using the
'orientation' optional argument, as follows:

from numpy import *
from scipy import *
from mpl_toolkits.axes_grid.axislines import SubplotZero
import matplotlib.pyplot as plt
fig = plt.figure()
ax = SubplotZero(fig, 3, 1, 1)
ax1 = fig.add_subplot(ax)
ax.axis["xzero"].set_visible(True)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
plt.ylabel("hello", rotation='horizontal')
ax = SubplotZero(fig, 3, 1, 2)
ax2 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
plt.ylabel("world")
ax = SubplotZero(fig, 3, 1, 3)
ax3 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.01, 3.01], label="line b", c='b')
plt.figlegend([ax1.lines[0], ax1.lines[1]], ["line a", "line b"], 'upper right')

but it does not work. both the labels "hello" and "world" of the y
axes are displayed in their default vertical orientation. the argument
seems to have no effect. i am using matplotlib '0.99.0' on Mac OS X.
any ideas how to fix this?

thanks.

First of all, I recommend you to use spines instead of SubplotZero of
axes_grid toolkit.

http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html

If you use axes_grid toolkit, keep in mind that some axis-related
command of matplotlib may not work. Please take a look at the
documentation.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#axisline

If something does not work, see if

ax.axis["xzero"].set_visible(True)

solves the problem. This will recover the original behavior of
matplotlib, but some functionality of axes_grid toolkit may not work
anymore.

To have a horizontal label with axes_grid,

ax.axis["left"].get_helper()._label_angles["left"]=0

While it is best if something like
ax.axis["left"].label.set_rotation("horizontal") work, but it does not
currently. I'll try to fix this in time but use one of the options
above.

Regards,

-JJ

ยทยทยท

On Sun, Oct 11, 2009 at 8:09 PM, per freem <perfreem@...287...> wrote:

hi all,

i am trying to make horizontal (as opposed to the default vertical)
rotated labels for axes in my subplots. i tried using the
'orientation' optional argument, as follows:

from numpy import *
from scipy import *
from mpl_toolkits.axes_grid.axislines import SubplotZero
import matplotlib.pyplot as plt
fig = plt.figure()
ax = SubplotZero(fig, 3, 1, 1)
ax1 = fig.add_subplot(ax)
ax.axis["xzero"].set_visible(True)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
plt.ylabel("hello", rotation='horizontal')
ax = SubplotZero(fig, 3, 1, 2)
ax2 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
plt.ylabel("world")
ax = SubplotZero(fig, 3, 1, 3)
ax3 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.01, 3.01], label="line b", c='b')
plt.figlegend([ax1.lines[0], ax1.lines[1]], ["line a", "line b"], 'upper right')

but it does not work. both the labels "hello" and "world" of the y
axes are displayed in their default vertical orientation. the argument
seems to have no effect. i am using matplotlib '0.99.0' on Mac OS X.
any ideas how to fix this?

thanks.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options