@@ -2689,3 +2689,87 @@ def test_ndarray_color_kwargs_value_error():
2689
2689
ax = fig .add_subplot (111 , projection = '3d' )
2690
2690
ax .scatter (1 , 0 , 0 , color = np .array ([0 , 0 , 0 , 1 ]))
2691
2691
fig .canvas .draw ()
2692
+
2693
+
2694
+ @check_figures_equal ()
2695
+ def test_plot_surface_shade_auto_with_facecolors (fig_test , fig_ref ):
2696
+ """Test that plot_surface with facecolors uses shade=False by default."""
2697
+ X = np .linspace (0 , 1 , 5 )
2698
+ Y = np .linspace (0 , 1 , 5 )
2699
+ X_mesh , Y_mesh = np .meshgrid (X , Y )
2700
+ Z = X_mesh + Y_mesh
2701
+ colors = cm .viridis (X_mesh )
2702
+
2703
+ # Test with facecolors (should have shade=False by default)
2704
+ ax_test = fig_test .add_subplot (projection = '3d' )
2705
+ ax_test .plot_surface (X_mesh , Y_mesh , Z , facecolors = colors )
2706
+
2707
+ # Reference with explicit shade=False
2708
+ ax_ref = fig_ref .add_subplot (projection = '3d' )
2709
+ ax_ref .plot_surface (X_mesh , Y_mesh , Z , facecolors = colors , shade = False )
2710
+
2711
+
2712
+ @check_figures_equal ()
2713
+ def test_plot_surface_shade_auto_without_facecolors (fig_test , fig_ref ):
2714
+ """Test that plot_surface without facecolors uses shade=True by default."""
2715
+ X = np .linspace (0 , 1 , 5 )
2716
+ Y = np .linspace (0 , 1 , 5 )
2717
+ X_mesh , Y_mesh = np .meshgrid (X , Y )
2718
+ Z = X_mesh + Y_mesh
2719
+
2720
+ # Test without facecolors (should have shade=True by default)
2721
+ ax_test = fig_test .add_subplot (projection = '3d' )
2722
+ ax_test .plot_surface (X_mesh , Y_mesh , Z )
2723
+
2724
+ # Reference with explicit shade=True
2725
+ ax_ref = fig_ref .add_subplot (projection = '3d' )
2726
+ ax_ref .plot_surface (X_mesh , Y_mesh , Z , shade = True )
2727
+
2728
+
2729
+ @check_figures_equal ()
2730
+ def test_plot_surface_shade_auto_with_cmap (fig_test , fig_ref ):
2731
+ """Test that plot_surface with cmap uses shade=False by default."""
2732
+ X = np .linspace (0 , 1 , 5 )
2733
+ Y = np .linspace (0 , 1 , 5 )
2734
+ X_mesh , Y_mesh = np .meshgrid (X , Y )
2735
+ Z = X_mesh + Y_mesh
2736
+
2737
+ # Test with cmap (should have shade=False by default)
2738
+ ax_test = fig_test .add_subplot (projection = '3d' )
2739
+ ax_test .plot_surface (X_mesh , Y_mesh , Z , cmap = cm .viridis )
2740
+
2741
+ # Reference with explicit shade=False
2742
+ ax_ref = fig_ref .add_subplot (projection = '3d' )
2743
+ ax_ref .plot_surface (X_mesh , Y_mesh , Z , cmap = cm .viridis , shade = False )
2744
+
2745
+
2746
+ @check_figures_equal ()
2747
+ def test_plot_surface_shade_override_with_facecolors (fig_test , fig_ref ):
2748
+ """Test that explicit shade parameter overrides auto behavior with facecolors."""
2749
+ X = np .linspace (0 , 1 , 5 )
2750
+ Y = np .linspace (0 , 1 , 5 )
2751
+ X_mesh , Y_mesh = np .meshgrid (X , Y )
2752
+ Z = X_mesh + Y_mesh
2753
+ colors = cm .viridis (X_mesh )
2754
+
2755
+ # Test with explicit shade=True (overrides auto behavior)
2756
+ ax_test = fig_test .add_subplot (projection = '3d' )
2757
+ ax_test .plot_surface (X_mesh , Y_mesh , Z , facecolors = colors , shade = True )
2758
+
2759
+ # Reference with explicit shade=True
2760
+ ax_ref = fig_ref .add_subplot (projection = '3d' )
2761
+ ax_ref .plot_surface (X_mesh , Y_mesh , Z , facecolors = colors , shade = True )
2762
+
2763
+
2764
+ def test_plot_surface_shade_with_cmap_raises ():
2765
+ """Test that shade=True with cmap raises an error."""
2766
+ X = np .linspace (0 , 1 , 5 )
2767
+ Y = np .linspace (0 , 1 , 5 )
2768
+ X_mesh , Y_mesh = np .meshgrid (X , Y )
2769
+ Z = X_mesh + Y_mesh
2770
+
2771
+ fig = plt .figure ()
2772
+ ax = fig .add_subplot (projection = '3d' )
2773
+
2774
+ with pytest .raises (ValueError , match = "Shading is not compatible with colormapping" ):
2775
+ ax .plot_surface (X_mesh , Y_mesh , Z , cmap = cm .viridis , shade = True )
0 commit comments