@@ -453,6 +453,38 @@ def test_tripcolor_warns_when_z_and_facecolors_given():
453453 )
454454
455455
456+ def test_spy_marker_path_takes_no_colormap ():
457+ """
458+ Marker-style spy must not be handed a colormap.
459+
460+ Matplotlib's spy draws an image when no marker is given and a Line2D of
461+ markers otherwise; only the image understands `cmap`, so parsing one for
462+ the marker path raised `Line2D.set() got an unexpected keyword argument`.
463+ """
464+ from matplotlib .image import AxesImage
465+ from matplotlib .lines import Line2D
466+
467+ matrix = np .random .default_rng (51423 ).random ((12 , 12 )) > 0.8
468+ _ , axs = uplt .subplots (ncols = 4 )
469+ assert isinstance (axs [0 ].spy (matrix ), AxesImage )
470+ assert isinstance (axs [1 ].spy (matrix , markersize = 2 ), Line2D )
471+ assert isinstance (axs [2 ].spy (matrix , marker = "s" ), Line2D )
472+ assert isinstance (axs [3 ].spy (matrix , color = "denim" , markersize = 3 ), Line2D )
473+
474+
475+ def test_spy_image_path_still_takes_a_colormap ():
476+ """
477+ The image path keeps its colormap handling, including the discrete default.
478+ """
479+ from matplotlib .image import AxesImage
480+
481+ matrix = np .random .default_rng (51423 ).random ((12 , 12 )) > 0.8
482+ _ , ax = uplt .subplots ()
483+ image = ax .spy (matrix , cmap = "Greys" )
484+ assert isinstance (image , AxesImage )
485+ assert "greys" in image .get_cmap ().name .lower ()
486+
487+
456488def test_tricontour_explicit_colors_match_levels ():
457489 """
458490 Explicit triangular contour colors should map one-to-one with levels.
0 commit comments