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

Commit71dd3ae

Browse files
authored
Merge pull request#13126 from jklymak/fix-minor-log
FIX: minor log ticks overwrite
2 parents910f9fd +1f70d7a commit71dd3ae

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

‎lib/matplotlib/tests/test_ticker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ def test_switch_to_autolocator(self):
183183
loc=mticker.LogLocator(subs="all")
184184
assert_array_equal(loc.tick_values(0.45,0.55),
185185
[0.44,0.46,0.48,0.5,0.52,0.54,0.56])
186+
# check that we *skip* 1.0, and 10, because this is a minor locator
187+
loc=mticker.LogLocator(subs=np.arange(2,10))
188+
assert1.0notinloc.tick_values(0.9,20.)
189+
assert10.0notinloc.tick_values(0.9,20.)
186190

187191
deftest_set_params(self):
188192
"""

‎lib/matplotlib/ticker.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,9 +2093,7 @@ def is_decade(x, base=10):
20932093

20942094

20952095
defis_close_to_int(x):
2096-
ifnotnp.isfinite(x):
2097-
returnFalse
2098-
returnabs(x-round(x))<1e-10
2096+
returnabs(x-np.round(x))<1e-10
20992097

21002098

21012099
classLogLocator(Locator):
@@ -2256,7 +2254,12 @@ def tick_values(self, vmin, vmax):
22562254
# If we're a minor locator *that expects at least two ticks per
22572255
# decade* and the major locator stride is 1 and there's no more
22582256
# than one minor tick, switch to AutoLocator.
2259-
returnAutoLocator().tick_values(vmin,vmax)
2257+
ticklocs=AutoLocator().tick_values(vmin,vmax)
2258+
# Don't overstrike the major labels. Assumes major locs are
2259+
# at b = self._base
2260+
ticklocs=ticklocs[
2261+
~is_close_to_int(np.log(ticklocs)/np.log(b))]
2262+
returnticklocs
22602263
returnself.raise_if_exceeds(ticklocs)
22612264

22622265
defview_limits(self,vmin,vmax):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp