@@ -1011,17 +1011,15 @@ def _set_artist_props(self, a):
10111011
10121012 def iter_ticks (self ):
10131013 """
1014- Iterate through all of the major and minor ticks.
1014+ Yield ``(Tick, location, label)`` tuples for major and minor ticks.
10151015 """
1016- major_locs = self .major .locator ()
1017- major_ticks = self .get_major_ticks (len (major_locs ))
1016+ major_locs = self .get_majorticklocs ()
10181017 major_labels = self .major .formatter .format_ticks (major_locs )
1019-
1020- minor_locs = self .minor .locator ()
1021- minor_ticks = self .get_minor_ticks (len (minor_locs ))
1022- minor_labels = self .minor .formatter .format_ticks (minor_locs )
1023-
1018+ major_ticks = self .get_major_ticks (len (major_locs ))
10241019 yield from zip (major_ticks , major_locs , major_labels )
1020+ minor_locs = self .get_minorticklocs ()
1021+ minor_labels = self .minor .formatter .format_ticks (minor_locs )
1022+ minor_ticks = self .get_minor_ticks (len (minor_locs ))
10251023 yield from zip (minor_ticks , minor_locs , minor_labels )
10261024
10271025 def get_ticklabel_extents (self , renderer ):
@@ -1297,18 +1295,29 @@ def get_ticklines(self, minor=False):
12971295 return self .get_majorticklines ()
12981296
12991297 def get_majorticklocs (self ):
1300- "Get the major tick locations in data coordinates as a numpy array "
1298+ """ Get the array of major tick locations in data coordinates."" "
13011299 return self .major .locator ()
13021300
13031301 def get_minorticklocs (self ):
1304- "Get the minor tick locations in data coordinates as a numpy array"
1305- return self .minor .locator ()
1302+ """Get the array of minor tick locations in data coordinates."""
1303+ # Remove minor ticks duplicating major ticks.
1304+ major_locs = self .major .locator ()
1305+ minor_locs = self .minor .locator ()
1306+ transform = self ._scale .get_transform ()
1307+ tr_minor_locs = transform .transform (minor_locs )
1308+ tr_major_locs = transform .transform (major_locs )
1309+ lo , hi = sorted (transform .transform (self .get_view_interval ()))
1310+ # Use the transformed view limits as scale. 1e-5 is the default rtol
1311+ # for np.isclose.
1312+ tol = (hi - lo ) * 1e-5
1313+ minor_locs = [
1314+ loc for loc , tr_loc in zip (minor_locs , tr_minor_locs )
1315+ if not np .isclose (tr_loc , tr_major_locs , atol = tol , rtol = 0 ).any ()]
1316+ return minor_locs
13061317
13071318 def get_ticklocs (self , minor = False ):
1308- "Get the tick locations in data coordinates as a numpy array"
1309- if minor :
1310- return self .minor .locator ()
1311- return self .major .locator ()
1319+ """Get the array of tick locations in data coordinates."""
1320+ return self .get_minorticklocs () if minor else self .get_majorticklocs ()
13121321
13131322 def get_ticks_direction (self , minor = False ):
13141323 """
0 commit comments