Skip to content

Commit

Permalink
Fixed bug disabling axis labels with labelled option (#2643)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed May 3, 2018
1 parent 3401b9c commit b8e96a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ def _update_plot(self, key, plot, element=None):
for axis, dim in zip(['x', 'y'], dimensions)}
xlabel, ylabel, zlabel = self._get_axis_labels(dimensions)
if self.invert_axes: xlabel, ylabel = ylabel, xlabel
props['x']['axis_label'] = xlabel
props['y']['axis_label'] = ylabel
props['x']['axis_label'] = xlabel if 'x' in self.labelled else ''
props['y']['axis_label'] = ylabel if 'y' in self.labelled else ''
recursive_model_update(plot.xaxis[0], props.get('x', {}))
recursive_model_update(plot.yaxis[0], props.get('y', {}))

Expand Down
20 changes: 19 additions & 1 deletion tests/plotting/bokeh/testelementplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_empty_element_visibility(self):
curve = Curve([])
plot = bokeh_renderer.get_plot(curve)
self.assertTrue(plot.handles['glyph_renderer'].visible)

def test_element_no_xaxis(self):
curve = Curve(range(10)).opts(plot=dict(xaxis=None))
plot = bokeh_renderer.get_plot(curve).state
Expand All @@ -48,6 +48,24 @@ def test_element_yrotation(self):
plot = bokeh_renderer.get_plot(curve).state
self.assertEqual(plot.yaxis[0].major_label_orientation, np.pi/2)

def test_element_labelled_x_disabled(self):
curve = Curve(range(10)).options(labelled=['y'])
plot = bokeh_renderer.get_plot(curve).state
self.assertEqual(plot.xaxis[0].axis_label, '')
self.assertEqual(plot.yaxis[0].axis_label, 'y')

def test_element_labelled_y_disabled(self):
curve = Curve(range(10)).options(labelled=['x'])
plot = bokeh_renderer.get_plot(curve).state
self.assertEqual(plot.xaxis[0].axis_label, 'x')
self.assertEqual(plot.yaxis[0].axis_label, '')

def test_element_labelled_both_disabled(self):
curve = Curve(range(10)).options(labelled=[])
plot = bokeh_renderer.get_plot(curve).state
self.assertEqual(plot.xaxis[0].axis_label, '')
self.assertEqual(plot.yaxis[0].axis_label, '')

def test_static_source_optimization(self):
global data
data = np.ones((5, 5))
Expand Down

0 comments on commit b8e96a6

Please sign in to comment.