Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2658eef

Browse files
authored
Merge pull request#13314 from anntzer/minoroverstrike
Move major/minor tick overstrike logic to Axis.
2 parentsfdfe898 +a752d46 commit2658eef

File tree

16 files changed

+63
-4484
lines changed

16 files changed

+63
-4484
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Minor Locator no longer try to avoid overstriking major Locators
2+
````````````````````````````````````````````````````````````````
3+
4+
Previously, certain locator classes (`LogLocator`, `AutoMinorLocator`)
5+
contained custom logic to avoid emitting tick locations that collided with
6+
major ticks when they were used as minor locators.
7+
8+
This logic has now moved to the Axis class; thus, for example,
9+
``xaxis.minor.locator()`` now includes positions that collide with
10+
``xaxis.major.locator()``, but ``xaxis.get_minorticklocs()`` does not.

‎lib/matplotlib/axis.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,17 +1011,15 @@ def _set_artist_props(self, a):
10111011

10121012
defiter_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
yieldfromzip(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
yieldfromzip(minor_ticks,minor_locs,minor_labels)
10261024

10271025
defget_ticklabel_extents(self,renderer):
@@ -1297,18 +1295,29 @@ def get_ticklines(self, minor=False):
12971295
returnself.get_majorticklines()
12981296

12991297
defget_majorticklocs(self):
1300-
"Get the major tick locations in data coordinates as a numpy array"
1298+
"""Get thearray ofmajor tick locations in data coordinates."""
13011299
returnself.major.locator()
13021300

13031301
defget_minorticklocs(self):
1304-
"Get the minor tick locations in data coordinates as a numpy array"
1305-
returnself.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+
locforloc,tr_locinzip(minor_locs,tr_minor_locs)
1315+
ifnotnp.isclose(tr_loc,tr_major_locs,atol=tol,rtol=0).any()]
1316+
returnminor_locs
13061317

13071318
defget_ticklocs(self,minor=False):
1308-
"Get the tick locations in data coordinates as a numpy array"
1309-
ifminor:
1310-
returnself.minor.locator()
1311-
returnself.major.locator()
1319+
"""Get the array of tick locations in data coordinates."""
1320+
returnself.get_minorticklocs()ifminorelseself.get_majorticklocs()
13121321

13131322
defget_ticks_direction(self,minor=False):
13141323
"""
Binary file not shown.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp