Skip to content
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

Fix xaxis/yaxis options with Matplotlib #5200

Merged
merged 3 commits into from
Feb 3, 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
4 changes: 2 additions & 2 deletions holoviews/plotting/mpl/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,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 @@ -324,7 +324,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/test_elementplot.py
Original file line number Diff line number Diff line change
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