@@ -106,6 +106,25 @@ def test_basic(self):
106106 (1 , 0 ) # a single major tick => no minor tick
107107 ]
108108
109+ def test_first_and_last_minorticks (self ):
110+ """
111+ Test that first and last minor tick appear as expected.
112+ """
113+ # This test is related to issue #22331
114+ fig , ax = plt .subplots ()
115+ ax .set_xlim (- 1.9 , 1.9 )
116+ ax .xaxis .set_minor_locator (mticker .AutoMinorLocator ())
117+ test_value = np .array ([- 1.9 , - 1.8 , - 1.7 , - 1.6 , - 1.4 , - 1.3 , - 1.2 , - 1.1 ,
118+ - 0.9 , - 0.8 , - 0.7 , - 0.6 , - 0.4 , - 0.3 , - 0.2 , - 0.1 ,
119+ 0.1 , 0.2 , 0.3 , 0.4 , 0.6 , 0.7 , 0.8 , 0.9 , 1.1 ,
120+ 1.2 , 1.3 , 1.4 , 1.6 , 1.7 , 1.8 , 1.9 ])
121+ assert_almost_equal (ax .xaxis .get_ticklocs (minor = True ), test_value )
122+
123+ ax .set_xlim (- 5 , 5 )
124+ test_value = np .array ([- 5.0 , - 4.5 , - 3.5 , - 3.0 , - 2.5 , - 1.5 , - 1.0 , - 0.5 ,
125+ 0.5 , 1.0 , 1.5 , 2.5 , 3.0 , 3.5 , 4.5 , 5.0 ])
126+ assert_almost_equal (ax .xaxis .get_ticklocs (minor = True ), test_value )
127+
109128 @pytest .mark .parametrize ('nb_majorticks, expected_nb_minorticks' , params )
110129 def test_low_number_of_majorticks (
111130 self , nb_majorticks , expected_nb_minorticks ):
0 commit comments