Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c721e9

Browse files
authored
Merge pull request #24439 from dstansby/polar-log
Remove custom polar behaviour in LogLocator
2 parents 4c4df7f + 832f4c8 commit 6c721e9

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ def test_basic(self):
208208
test_value = np.array([0.5, 1., 2., 4., 8., 16., 32., 64., 128., 256.])
209209
assert_almost_equal(loc.tick_values(1, 100), test_value)
210210

211+
def test_polar_axes(self):
212+
"""
213+
Polar axes have a different ticking logic.
214+
"""
215+
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
216+
ax.set_yscale('log')
217+
ax.set_ylim(1, 100)
218+
assert_array_equal(ax.get_yticks(), [10, 100, 1000])
219+
211220
def test_switch_to_autolocator(self):
212221
loc = mticker.LogLocator(subs="all")
213222
assert_array_equal(loc.tick_values(0.45, 0.55),

lib/matplotlib/ticker.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,14 +2352,6 @@ def tick_values(self, vmin, vmax):
23522352
numticks = self.numticks
23532353

23542354
b = self._base
2355-
# dummy axis has no axes attribute
2356-
if hasattr(self.axis, 'axes') and self.axis.axes.name == 'polar':
2357-
vmax = math.ceil(math.log(vmax) / math.log(b))
2358-
decades = np.arange(vmax - self.numdecs, vmax)
2359-
ticklocs = b ** decades
2360-
2361-
return ticklocs
2362-
23632355
if vmin <= 0.0:
23642356
if self.axis is not None:
23652357
vmin = self.axis.get_minpos()
@@ -2444,10 +2436,6 @@ def view_limits(self, vmin, vmax):
24442436

24452437
vmin, vmax = self.nonsingular(vmin, vmax)
24462438

2447-
if self.axis.axes.name == 'polar':
2448-
vmax = math.ceil(math.log(vmax) / math.log(b))
2449-
vmin = b ** (vmax - self.numdecs)
2450-
24512439
if mpl.rcParams['axes.autolimit_mode'] == 'round_numbers':
24522440
vmin = _decade_less_equal(vmin, self._base)
24532441
vmax = _decade_greater_equal(vmax, self._base)

0 commit comments

Comments
 (0)