Skip to content

Commit

Permalink
Fix xaxis/yaxis options with Matplotlib (#5200)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored and jlstevens committed Feb 7, 2022
1 parent 6506684 commit ef671af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/mpl/element.py
Expand Up @@ -174,7 +174,7 @@ def _finalize_axis(self, key, element=None, title=None, dimensions=None, ranges=
if self.logy:
axis.set_yscale('log')

if not isinstance(self.projection, str) and self.projection == '3d':
if not (isinstance(self.projection, str) and self.projection == '3d'):
self._set_axis_position(axis, 'x', self.xaxis)
self._set_axis_position(axis, 'y', self.yaxis)

Expand Down Expand Up @@ -330,7 +330,7 @@ def _set_axis_limits(self, axis, view, subplots, ranges):
coords = [coord if isinstance(coord, np.datetime64) or np.isreal(coord) else np.NaN for coord in extents]
coords = [date2num(util.dt64_to_dt(c)) if isinstance(c, np.datetime64) else c
for c in coords]
if isinstance(self.projection, str) and self.projection == '3d' or len(extents) == 6:
if (isinstance(self.projection, str) and self.projection == '3d') or len(extents) == 6:
l, b, zmin, r, t, zmax = coords
if self.invert_zaxis or any(p.invert_zaxis for p in subplots):
zmin, zmax = zmax, zmin
Expand Down
8 changes: 8 additions & 0 deletions holoviews/tests/plotting/matplotlib/testelementplot.py
Expand Up @@ -59,6 +59,14 @@ def test_element_font_scaling_fontsize_override_specific(self):
self.assertEqual(ax.xaxis._major_tick_kw['labelsize'], 24)
self.assertEqual(ax.yaxis._major_tick_kw['labelsize'], 20)

def test_element_no_xaxis_yaxis(self):
element = Curve(range(10)).options(xaxis=None, yaxis=None)
axes = mpl_renderer.get_plot(element).handles['axis']
xaxis = axes.get_xaxis()
yaxis = axes.get_yaxis()
self.assertEqual(xaxis.get_visible(), False)
self.assertEqual(yaxis.get_visible(), False)

def test_element_xlabel(self):
element = Curve(range(10)).options(xlabel='custom x-label')
axes = mpl_renderer.get_plot(element).handles['axis']
Expand Down

0 comments on commit ef671af

Please sign in to comment.