3D plot -- rotating axes label text?

Hi,

I have not managed to rotate the axes label text when generating a 3D plot, while in 2D everything works just fine. Here's a short snippet to demonstrate:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.set_zlabel('label text flipped', rotation=45)

ax.azim = 225

plt.show()

I've tried other commands like:
ax.w_zaxis.set_label_text(r'$\left ( \frac{R}{R_{ref}} \right )^{2}$', rotation='vertical')
without success. I would prefer not to use a solution like "pathpatch3d_demo.py" because then I need to find the location separately. Any suggestions?

Cheers,
Sami

Because mplot3d has to managed the rotation of the axes label text itself, it over-rides any user-specified rotations. I guess it is feasible to apply a rotation on top of the internal rotation. Could you file a feature request on github for this?

Cheers!
Ben Root

···

On Tue, Jul 24, 2012 at 10:10 AM, Sami Niemi <s.niemi@…1055…> wrote:

Hi,

I have not managed to rotate the axes label text when generating a 3D plot, while in 2D everything works just fine. Here’s a short snippet to demonstrate:

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()

ax = fig.add_subplot(111, projection=‘3d’)

ax.set_zlabel(‘label text flipped’, rotation=45)

ax.azim = 225

plt.show()

Thanks Ben for your explanation. I have filed a feature request:

https://github.com/matplotlib/matplotlib/issues/1037

Cheers,

Sami

···

On 24 Jul 2012, at 15:39, Benjamin Root wrote:

On Tue, Jul 24, 2012 at 10:10 AM, Sami Niemi <s.niemi@…1055…> wrote:

Hi,

I have not managed to rotate the axes label text when generating a 3D plot, while in 2D everything works just fine. Here’s a short snippet to demonstrate:

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()

ax = fig.add_subplot(111, projection=‘3d’)

ax.set_zlabel(‘label text flipped’, rotation=45)

ax.azim = 225

plt.show()

Because mplot3d has to managed the rotation of the axes label text itself, it over-rides any user-specified rotations. I guess it is feasible to apply a rotation on top of the internal rotation. Could you file a feature request on github for this?

Cheers!
Ben Root

Sami,

I did take a quick peek at the code to assess how much effort it would take to make it work properly. It isn’t trivial, to say the least, because the user-supplied rotation value is overwritten in order to do the 3d-managed rotation. This is actually similar to another problem where user-supplied colors to scatter plots would be over-written as one interacts with the plot.

I have a possible quickfix in mind, but I have to test it out, and I already know of some edge cases where it won’t work. But it might be sufficient for most use-cases.

Cheers!
Ben Root

···

On Tue, Jul 24, 2012 at 10:52 AM, Sami Niemi <s.niemi@…1055…> wrote:

Thanks Ben for your explanation. I have filed a feature request:

https://github.com/matplotlib/matplotlib/issues/1037

Cheers,

Sami