Skip to content

Remove custom polar behaviour in LogLocator #24439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ def test_basic(self):
test_value = np.array([0.5, 1., 2., 4., 8., 16., 32., 64., 128., 256.])
assert_almost_equal(loc.tick_values(1, 100), test_value)

def test_polar_axes(self):
"""
Polar axes have a different ticking logic.
"""
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.set_yscale('log')
ax.set_ylim(1, 100)
assert_array_equal(ax.get_yticks(), [10, 100, 1000])

def test_switch_to_autolocator(self):
loc = mticker.LogLocator(subs="all")
assert_array_equal(loc.tick_values(0.45, 0.55),
Expand Down
12 changes: 0 additions & 12 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2352,14 +2352,6 @@ def tick_values(self, vmin, vmax):
numticks = self.numticks

b = self._base
# dummy axis has no axes attribute
if hasattr(self.axis, 'axes') and self.axis.axes.name == 'polar':
vmax = math.ceil(math.log(vmax) / math.log(b))
decades = np.arange(vmax - self.numdecs, vmax)
ticklocs = b ** decades

return ticklocs

if vmin <= 0.0:
if self.axis is not None:
vmin = self.axis.get_minpos()
Expand Down Expand Up @@ -2444,10 +2436,6 @@ def view_limits(self, vmin, vmax):

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

if self.axis.axes.name == 'polar':
vmax = math.ceil(math.log(vmax) / math.log(b))
vmin = b ** (vmax - self.numdecs)

if mpl.rcParams['axes.autolimit_mode'] == 'round_numbers':
vmin = _decade_less_equal(vmin, self._base)
vmax = _decade_greater_equal(vmax, self._base)
Expand Down