8000 test: add 3D scatter test for cmap update (#30062) · matplotlib/matplotlib@35c5481 · GitHub
[go: up one dir, main page]

Skip to content

Commit 35c5481

Browse files
authored
test: add 3D scatter test for cmap update (#30062)
1 parent 3faa9f8 commit 35c5481

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/matplotlib/tests/test_collections.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,28 @@ def test_polycollection_close():
492492
ax.set_ylim3d(0, 4)
493493

494494

495+
@check_figures_equal(extensions=["png"])
496+
def test_scalarmap_change_cmap(fig_test, fig_ref):
497+
# Ensure that changing the colormap of a 3D scatter after draw updates the colors.
498+
499+
x, y, z = np.array(list(itertools.product(
500+
np.arange(0, 5, 1),
501+
np.arange(0, 5, 1),
502+
np.arange(0, 5, 1)
503+
))).T
504+
c = x + y
505+
506+
# test
507+
ax_test = fig_test.add_subplot(111, projection='3d')
508+
sc_test = ax_test.scatter(x, y, z, c=c, s=40, cmap='jet')
509+
fig_test.canvas.draw()
510+
sc_test.set_cmap('viridis')
511+
512+
# ref
513+
ax_ref = fig_ref.add_subplot(111, projection='3d')
514+
ax_ref.scatter(x, y, z, c=c, s=40, cmap='viridis')
515+
516+
495517
@image_comparison(['regularpolycollection_rotate.png'], remove_text=True)
496518
def test_regularpolycollection_rotate():
497519
xx, yy = np.mgrid[:10, :10]

0 commit comments

Comments
 (0)
0