diff --git a/holoviews/plotting/mpl/element.py b/holoviews/plotting/mpl/element.py index 4ac7feb08d..a4de5a79a4 100644 --- a/holoviews/plotting/mpl/element.py +++ b/holoviews/plotting/mpl/element.py @@ -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 diff --git a/holoviews/tests/plotting/matplotlib/test_elementplot.py b/holoviews/tests/plotting/matplotlib/test_elementplot.py index 8130817f43..cd3f06dfff 100644 --- a/holoviews/tests/plotting/matplotlib/test_elementplot.py +++ b/holoviews/tests/plotting/matplotlib/test_elementplot.py @@ -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): @@ -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):