Skip to content

Commit

Permalink
Added labelled plot option for bokeh plots
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 16, 2016
1 parent 3b8c068 commit f921f4a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class ElementPlot(BokehPlot, GenericElementPlot):
invert_yaxis = param.Boolean(default=False, doc="""
Whether to invert the plot y-axis.""")

labelled = param.List(default=['x', 'y'], doc="""
Whether to plot the 'x' and 'y' labels.""")

lod = param.Dict(default={'factor': 10, 'interval': 300,
'threshold': 2000, 'timeout': 500}, doc="""
Bokeh plots offer "Level of Detail" (LOD) capability to
Expand Down Expand Up @@ -161,8 +164,7 @@ class ElementPlot(BokehPlot, GenericElementPlot):
# instance attribute.
_update_handles = ['source', 'glyph']

def __init__(self, element, plot=None, show_labels=['x', 'y'], **params):
self.show_labels = show_labels
def __init__(self, element, plot=None, **params):
self.current_ranges = None
super(ElementPlot, self).__init__(element, **params)
self.handles = {} if plot is None else self.handles['plot']
Expand Down Expand Up @@ -285,8 +287,8 @@ def _init_plot(self, key, element, plots, ranges=None):
xlabel, ylabel, _ = labels
x_axis_type, y_axis_type = axis_types
properties = dict(plot_ranges)
properties['x_axis_label'] = xlabel if 'x' in self.show_labels else ' '
properties['y_axis_label'] = ylabel if 'y' in self.show_labels else ' '
properties['x_axis_label'] = xlabel if 'x' in self.labelled else ' '
properties['y_axis_label'] = ylabel if 'y' in self.labelled else ' '

if self.show_title:
title = self._format_title(key, separator=' ')
Expand Down
4 changes: 2 additions & 2 deletions holoviews/plotting/bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,11 @@ def _create_subplots(self, layout, positions, layout_dimensions, ranges, num=0):
yaxis = 'right-bare' if 'bare' in plot_type.yaxis else 'right'
side_opts = dict(height=main_plot.height, yaxis=yaxis,
width=plot_type.width, invert_axes=True,
show_labels=['y'], xticks=1, xaxis=main_plot.xaxis)
labelled=['y'], xticks=1, xaxis=main_plot.xaxis)
else:
xaxis = 'top-bare' if 'bare' in plot_type.xaxis else 'top'
side_opts = dict(width=main_plot.width, xaxis=xaxis,
height=plot_type.height, show_labels=['x'],
height=plot_type.height, labelled=['x'],
yticks=1, yaxis=main_plot.yaxis)

# Override the plotopts as required
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/bokeh/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TablePlot(BokehPlot, GenericElementPlot):

_update_handles = ['source', 'glyph']

def __init__(self, element, plot=None, show_labels=['x', 'y'], **params):
def __init__(self, element, plot=None, **params):
super(TablePlot, self).__init__(element, **params)
self.handles = {} if plot is None else self.handles['plot']
element_ids = self.hmap.traverse(lambda x: id(x), [Dataset, ItemTable])
Expand Down

0 comments on commit f921f4a

Please sign in to comment.