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

Skip to content

Commit 5e1133b

Browse files
authored
Merge pull request #12292 from eric-wieser/bar3d-subplot-tests
TST: Modify the bar3d test to show three more angles
2 parents 47bfac4 + a78790b commit 5e1133b

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

50.3 KB
Loading

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,21 @@ def test_bar3d():
2727
extensions=['png']
2828
)
2929
def test_bar3d_shaded():
30-
fig = plt.figure()
31-
ax = fig.add_subplot(111, projection='3d')
3230
x = np.arange(4)
3331
y = np.arange(5)
3432
x2d, y2d = np.meshgrid(x, y)
3533
x2d, y2d = x2d.ravel(), y2d.ravel()
3634
z = x2d + y2d
37-
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z, shade=True)
35+
36+
views = [(-60, 30), (30, 30), (30, -30), (120, -30)]
37+
fig = plt.figure(figsize=plt.figaspect(1 / len(views)))
38+
axs = fig.subplots(
39+
1, len(views),
40+
subplot_kw=dict(projection='3d')
41+
)
42+
for ax, (azim, elev) in zip(axs, views):
43+
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z, shade=True)
44+
ax.view_init(azim=azim, elev=elev)
3845
fig.canvas.draw()
3946

4047

0 commit comments

Comments
 (0)