@@ -8920,3 +8920,46 @@ def test_axhvlinespan_interpolation():
8920
8920
ax .axhline (1 , c = "C0" , alpha = .5 )
8921
8921
ax .axhspan (.8 , .9 , fc = "C1" , alpha = .5 )
8922
8922
ax .axhspan (.6 , .7 , .8 , .9 , fc = "C2" , alpha = .5 )
8923
+
8924
+
8925
+ @check_figures_equal (extensions = ["png" ])
8926
+ @pytest .mark .parametrize ("which" , ("x" , "y" ))
8927
+ def test_axes_clear_behavior (fig_ref , fig_test , which ):
8928
+ """Test that the given tick params are not reset by ax.clear()."""
8929
+ ax_test = fig_test .subplots ()
8930
+ ax_ref = fig_ref .subplots ()
8931
+ # the following tick params values are chosen to each create a visual difference
8932
+ # from their defaults
8933
+ target = {
8934
+ "direction" : "in" ,
8935
+ "length" : 10 ,
8936
+ "width" : 10 ,
8937
+ "color" : "xkcd:wine red" ,
8938
+ "pad" : 0 ,
8939
+ "labelfontfamily" : "serif" ,
8940
+ "zorder" : 7 ,
8941
+ "labelrotation" : 45 ,
8942
+ "labelcolor" : "xkcd:shocking pink" ,
8943
+ # this overrides color + labelcolor, skip
8944
+ # colors: ,
8945
+ "grid_color" : "xkcd:fluorescent green" ,
8946
+ "grid_alpha" : 0.5 ,
8947
+ "grid_linewidth" : 3 ,
8948
+ "grid_linestyle" : ":" ,
8949
+ "bottom" : False ,
8950
+ "top" : True ,
8951
+ "left" : False ,
8952
+ "right" : True ,
8953
+ "labelbottom" : True ,
8954
+ "labeltop" : True ,
8955
+ "labelleft" : True ,
8956
+ "labelright" : True ,
8957
+ }
8958
+
8959
+ ax_ref .tick_params (axis = which , ** target )
8960
+
8961
+ ax_test .tick_params (axis = which , ** target )
8962
+ ax_test .clear ()
8963
+
8964
+ ax_ref .grid (True )
8965
+ ax_test .grid (True )
0 commit comments