Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 660ea35

Browse files
authored
Merge pull request #28246 from meeseeksmachine/auto-backport-of-pr-28243-on-v3.9.x
Backport PR #28243 on branch v3.9.x (DOC: Add more 3D plot types)
2 parents 0281634 + 9f70709 commit 660ea35

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
==========================
3+
bar3d(x, y, z, dx, dy, dz)
4+
==========================
5+
6+
See `~mpl_toolkits.mplot3d.axes3d.Axes3D.bar3d`.
7+
"""
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
11+
plt.style.use('_mpl-gallery')
12+
13+
# Make data
14+
x = [1, 1, 2, 2]
15+
y = [1, 2, 1, 2]
16+
z = [0, 0, 0, 0]
17+
dx = np.ones_like(x)*0.5
18+
dy = np.ones_like(x)*0.5
19+
dz = [2, 3, 1, 4]
20+
21+
# Plot
22+
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
23+
ax.bar3d(x, y, z, dx, dy, dz)
24+
25+
ax.set(xticklabels=[],
26+
yticklabels=[],
27+
zticklabels=[])
28+
29+
plt.show()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
================
3+
plot(xs, ys, zs)
4+
================
5+
6+
See `~mpl_toolkits.mplot3d.axes3d.Axes3D.plot`.
7+
"""
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
11+
plt.style.use('_mpl-gallery')
12+
13+
# Make data
14+
n = 100
15+
xs = np.linspace(0, 1, n)
16+
ys = np.sin(xs * 6 * np.pi)
17+
zs = np.cos(xs * 6 * np.pi)
18+
19+
# Plot
20+
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
21+
ax.plot(xs, ys, zs)
22+
23+
ax.set(xticklabels=[],
24+
yticklabels=[],
25+
zticklabels=[])
26+
27+
plt.show()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
========================
3+
quiver(X, Y, Z, U, V, W)
4+
========================
5+
6+
See `~mpl_toolkits.mplot3d.axes3d.Axes3D.quiver`.
7+
"""
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
11+
plt.style.use('_mpl-gallery')
12+
13+
# Make data
14+
n = 4
15+
x = np.linspace(-1, 1, n)
16+
y = np.linspace(-1, 1, n)
17+
z = np.linspace(-1, 1, n)
18+
X, Y, Z = np.meshgrid(x, y, z)
19+
U = (X + Y)/5
20+
V = (Y - X)/5
21+
W = Z*0
22+
23+
24+
# Plot
25+
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
26+
ax.quiver(X, Y, Z, U, V, W)
27+
28+
ax.set(xticklabels=[],
29+
yticklabels=[],
30+
zticklabels=[])
31+
32+
plt.show()

galleries/plot_types/3D/stem3d.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
=============
3+
stem(x, y, z)
4+
=============
5+
6+
See `~mpl_toolkits.mplot3d.axes3d.Axes3D.stem`.
7+
"""
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
11+
plt.style.use('_mpl-gallery')
12+
13+
# Make data
14+
n = 20
15+
x = np.sin(np.linspace(0, 2*np.pi, n))
16+
y = np.cos(np.linspace(0, 2*np.pi, n))
17+
z = np.linspace(0, 1, n)
18+
19+
# Plot
20+
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
21+
ax.stem(x, y, z)
22+
23+
ax.set(xticklabels=[],
24+
yticklabels=[],
25+
zticklabels=[])
26+
27+
plt.show()

0 commit comments

Comments
 (0)