Skip to content

Commit d6da94c

Browse files
committed
Add tests for stem3d.
These are somewhat like the original tests in #6271, but consolidated into fewer images, and testing more properties.
1 parent f08ecc0 commit d6da94c

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,3 +1172,37 @@ def test_colorbar_pos():
11721172
fig.canvas.draw()
11731173
# check that actually on the bottom
11741174
assert cbar.ax.get_position().extents[1] < 0.2
1175+
1176+
1177+
@image_comparison(['stem3d.png'], style='mpl20')
1178+
def test_stem3d():
1179+
theta = np.linspace(0, 2*np.pi)
1180+
x = np.cos(theta - np.pi/2)
1181+
y = np.sin(theta - np.pi/2)
1182+
z = theta
1183+
1184+
fig, axs = plt.subplots(1, 3, figsize=(8, 3),
1185+
constrained_layout=True,
1186+
subplot_kw={'projection': '3d'})
1187+
for ax, zdir in zip(axs, ['x', 'y', 'z']):
1188+
ax.stem(x, y, z, orientation=zdir)
1189+
ax.set_title(f'orientation={zdir}')
1190+
1191+
1192+
@image_comparison(baseline_images=['stem3d_options.png'], style='mpl20')
1193+
def test_stem3d_options():
1194+
x = np.linspace(-np.pi/2, np.pi/2, 20)
1195+
y = np.ones_like(x)
1196+
z = np.cos(x)
1197+
1198+
fig, axs = plt.subplots(1, 3, figsize=(8, 3),
1199+
constrained_layout=True,
1200+
subplot_kw={'projection': '3d'})
1201+
for ax, zdir in zip(axs, ['x', 'y', 'z']):
1202+
markerline, stemlines, baseline = ax.stem(
1203+
x, y, z,
1204+
linefmt='C4-.', markerfmt='C1D', basefmt='C2',
1205+
orientation=zdir)
1206+
ax.set_title(f'orientation={zdir}')
1207+
markerline.set(markerfacecolor='none', markeredgewidth=2)
1208+
baseline.set_linewidth(3)

0 commit comments

Comments
 (0)