Skip to content

Don't default to negative radii in polar plot. #16300

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
Jan 23, 2020
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
6 changes: 6 additions & 0 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class RadialLocator(mticker.Locator):
:class:`~matplotlib.ticker.Locator` (which may be different
depending on the scale of the *r*-axis.
"""

def __init__(self, base, axes=None):
self.base = base
self._axes = axes
Expand Down Expand Up @@ -416,6 +417,11 @@ def refresh(self):
# docstring inherited
return self.base.refresh()

def nonsingular(self, vmin, vmax):
# docstring inherited
return ((0, 1) if (vmin, vmax) == (-np.inf, np.inf) # Init. limits.
else self.base.nonsingular(vmin, vmax))

def view_limits(self, vmin, vmax):
vmin, vmax = self.base.view_limits(vmin, vmax)
if vmax > vmin:
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,17 @@ def test_log_scales_invalid():
ax.set_ylim(-1, 10)


def test_polar_no_data():
plt.subplot(projection="polar")
ax = plt.gca()
assert ax.get_rmin() == 0 and ax.get_rmax() == 1
plt.close("all")
# Used to behave differently (by triggering an autoscale with no data).
plt.polar()
ax = plt.gca()
assert ax.get_rmin() == 0 and ax.get_rmax() == 1


@image_comparison(['stackplot_test_image', 'stackplot_test_image'])
def test_stackplot():
fig = plt.figure()
Expand Down