Skip to content

Commit

Permalink
Fix polar limits when using polar axes(#5397)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Aug 19, 2022
1 parent 4c118b3 commit 15eaae8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions holoviews/plotting/mpl/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ def _set_axis_limits(self, axis, view, subplots, ranges):
axis.set_zlim(bottom=zmin)
if valid_lim(zmax):
axis.set_zlim(top=zmax)
elif isinstance(self.projection, str) and self.projection == "polar":
_, b, _, t = coords
l = 0
r = 2 * np.pi
else:
l, b, r, t = coords

Expand Down
10 changes: 10 additions & 0 deletions holoviews/tests/plotting/matplotlib/test_elementplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from .test_plot import TestMPLPlot, mpl_renderer

from matplotlib.ticker import FormatStrFormatter, FuncFormatter, PercentFormatter
from matplotlib.projections import PolarAxes


class TestElementPlot(TestMPLPlot):

Expand Down Expand Up @@ -149,6 +151,14 @@ def test_element_zformatter_instance(self):
zformatter = zaxis.get_major_formatter()
self.assertIs(zformatter, formatter)

def test_element_polar_xlimits(self):
theta = np.arange(0, 5.4, 0.1)
r = np.ones(len(theta))
scatter = Scatter((theta, r), 'theta', 'r').opts(projection='polar')
plot = mpl_renderer.get_plot(scatter)
ax = plot.handles['axis']
self.assertIsInstance(ax, PolarAxes)
self.assertEqual(ax.get_xlim(), (0, 2 * np.pi))


class TestColorbarPlot(TestMPLPlot):
Expand Down

0 comments on commit 15eaae8

Please sign in to comment.