How to rotate 3D text in python?

Viewed 442

I tried rotation, but it does not work.

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D                         # 3d graph
from mpl_toolkits.mplot3d import proj3d                         # 3d graph
fig = plt.figure(figsize=[5,6])
ax = fig.gca(projection='3d')
ax.text(0, 0, 8.8, '$z$', 'z')    
plt.show()

enter image description here

1 Answers

Try this ax.set_zlabel('z-label', rotation=90), I hope this works.

Edit

The documentation outlines how generic text can be rotated in 3D. Given a 3D figure, one can add text via:

ax.text(x, y, z, label, direction)

The direction argument controls the rotation, and it is either:

  1. A 3-tuple specifying (x, y, z) directions
  2. 'x', 'y', or 'z', specifying that the text should run parallel to the specified axis.
Related