@@ -106,6 +106,26 @@ def test_basic(self):
106
106
(1 , 0 ) # a single major tick => no minor tick
107
107
]
108
108
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 = plt .figure ()
115
+ ax = plt .gca ()
116
+ ax .set_xlim (- 1.9 , 1.9 )
117
+ ax .xaxis .set_minor_locator (mticker .AutoMinorLocator ())
118
+ test_value = np .array ([- 1.9 , - 1.8 , - 1.7 , - 1.6 , - 1.4 , - 1.3 , - 1.2 , - 1.1 ,
119
+ - 0.9 , - 0.8 , - 0.7 , - 0.6 , - 0.4 , - 0.3 , - 0.2 , - 0.1 ,
120
+ 0.1 , 0.2 , 0.3 , 0.4 , 0.6 , 0.7 , 0.8 , 0.9 , 1.1 ,
121
+ 1.2 , 1.3 , 1.4 , 1.6 , 1.7 , 1.8 , 1.9 ])
122
+ assert_almost_equal (ax .xaxis .get_ticklocs (minor = True ), test_value )
123
+
124
+ ax .set_xlim (- 5 , 5 )
125
+ test_value = np .array ([- 5.0 , - 4.5 , - 3.5 , - 3.0 , - 2.5 , - 1.5 , - 1.0 , - 0.5 ,
126
+ 0.5 , 1.0 , 1.5 , 2.5 , 3.0 , 3.5 , 4.5 , 5.0 ])
127
+ assert_almost_equal (ax .xaxis .get_ticklocs (minor = True ), test_value )
128
+
109
129
@pytest .mark .parametrize ('nb_majorticks, expected_nb_minorticks' , params )
110
130
def test_low_number_of_majorticks (
111
131
self , nb_majorticks , expected_nb_minorticks ):
0 commit comments