diff --git a/holoviews/plotting/bokeh/chart.py b/holoviews/plotting/bokeh/chart.py index 349a6a1f10..491585bfc7 100644 --- a/holoviews/plotting/bokeh/chart.py +++ b/holoviews/plotting/bokeh/chart.py @@ -1068,12 +1068,12 @@ def get_data(self, element, ranges, style): data = { bar_glyph+'_1': r1_data, bar_glyph+'_2': r2_data, 'segment_1': s1_data, 'segment_2': s2_data, 'rect_1': w1_data, 'rect_2': w2_data, - 'circle': out_data + 'circle_1': out_data } mapping = { bar_glyph+'_1': vbar_map, bar_glyph+'_2': vbar2_map, 'segment_1': seg_map, 'segment_2': seg_map, 'rect_1': whisk_map, 'rect_2': whisk_map, - 'circle': out_map + 'circle_1': out_map } # Cast data to arrays to take advantage of base64 encoding diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index ffbac8efa0..2ea9d4a400 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -668,7 +668,8 @@ def _glyph_properties(self, plot, element, source, ranges, style): self.overlay_dims.items()]) else: legend = element.label - properties['legend'] = value(legend) + if legend: + properties['legend'] = value(legend) return properties def _update_glyph(self, renderer, properties, mapping, glyph): @@ -921,9 +922,12 @@ class CompositeElementPlot(ElementPlot): drawing of multiple glyphs. """ - # Mapping between glyph name and style groups + # Mapping between style groups and glyph names _style_groups = {} + # Defines the order in which glyphs are drawn, defined by glyph name + _draw_order = [] + def _init_glyphs(self, plot, element, ranges, source): # Get data and initialize data source style = self.style[self.cyclic_index] @@ -983,7 +987,13 @@ def _update_glyphs(self, element, ranges): style = self.style[self.cyclic_index] data, mapping, style = self.get_data(element, ranges, style) - for key in sorted(dict(mapping, **data)): + # Order glyphs by supplied draw order + keys = sorted(dict(mapping, **data)) + def order_fn(glyph): + matches = [item for item in self._draw_order if glyph.startswith(item)] + if matches: return self._draw_order.index(matches[0]) + return 1e6+keys.index(glyph) + for key in sorted(keys, key=order_fn): gdata = data.get(key) source = self.handles[key+'_source'] glyph = self.handles.get(key+'_glyph') @@ -1003,7 +1013,7 @@ def _init_glyph(self, plot, mapping, properties, key): Returns a Bokeh glyph object. """ properties = mpl_to_bokeh(properties) - plot_method = key.split('_')[0] + plot_method = '_'.join(key.split('_')[:-1]) renderer = getattr(plot, plot_method)(**dict(properties, **mapping)) return renderer, renderer.glyph