Skip to content

Commit f3b3242

Browse files
committed
Added missing mplot3d/offset_demo.py example
1 parent 47ce205 commit f3b3242

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

examples/mplot3d/offset_demo.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from mpl_toolkits.mplot3d import Axes3D
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
5+
# This example demonstrates mplot3d's offset text display.
6+
# As one rotates the 3D figure, the offsets should remain oriented
7+
# same way as the axis label, and should also be located "away"
8+
# from the center of the plot.
9+
#
10+
# This demo triggers the display of the offset text for the x and
11+
# y axis by adding 1e5 to X and Y. Anything less would not
12+
# automatically trigger it.
13+
14+
fig = plt.figure()
15+
ax = fig.gca(projection='3d')
16+
X, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.25]
17+
Z = np.sqrt(np.abs(np.cos(X) + np.cos(Y)))
18+
19+
surf = ax.plot_surface(X + 1e5, Y + 1e5, Z, cmap='autumn', cstride=2, rstride=2)
20+
ax.set_xlabel("X-Label")
21+
ax.set_ylabel("Y-Label")
22+
ax.set_zlabel("Z-Label")
23+
ax.set_zlim(0, 2)
24+
25+
plt.show()
26+

0 commit comments

Comments
 (0)