From 836d4ad204ac4a0b3825c3b145a22b4245ce49ee Mon Sep 17 00:00:00 2001 From: Andrew Huang Date: Sat, 6 Oct 2018 11:38:29 -0700 Subject: [PATCH] Figured out that dictionary was referenced and not copied --- holoviews/plotting/bokeh/element.py | 35 ++++++++++++----------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index 08f6317ddd..9629e386a2 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -5,7 +5,6 @@ import numpy as np import bokeh import bokeh.plotting -from holoviews.plotting.bokeh.util import bokeh_version from bokeh.core.properties import value from bokeh.models import (HoverTool, Renderer, Range1d, DataRange1d, Title, FactorRange, FuncTickFormatter, Tool, Legend, @@ -19,10 +18,7 @@ from bokeh.models.mappers import LogColorMapper, CategoricalColorMapper except ImportError: LogColorMapper, ColorBar = None, None -if bokeh_version <= '0.13.0': - built_in_themes = {} -else: - from bokeh.themes import built_in_themes +from holoviews.plotting.bokeh.util import theme_attr_json from bokeh.plotting.helpers import _known_tools as known_tools from ...core import DynamicMap, CompositeOverlay, Element, Dimension @@ -405,11 +401,8 @@ def _axis_properties(self, axis, key, plot, dimension=None, Returns a dictionary of axis properties depending on the specified axis. """ - try: - axis_props = (built_in_themes[self.renderer.theme] - ._json['attrs'].get('Axis', {})) - except KeyError: - axis_props = {} + # need to copy dictionary + axis_props = dict(theme_attr_json(self.renderer.theme, 'Axis')) if ((axis == 'x' and self.xaxis in ['bottom-bare', 'top-bare']) or (axis == 'y' and self.yaxis in ['left-bare', 'right-bare'])): @@ -473,17 +466,15 @@ def _axis_properties(self, axis, key, plot, dimension=None, axis_props['formatter'] = formatter if axis == 'x': - xaxis = plot.xaxis[0] - if isinstance(xaxis, CategoricalAxis): - # can't just dump this with the rest of axis_props - # always complains about LinearAxis does not have - # 'group_...' attribute - group_label_props = {} - for key in list(axis_props): - if key.startswith('major_label'): - new_key = key.replace('major_label', 'group') - group_label_props[new_key] = axis_props[key] - xaxis.update(**group_label_props) + axis_obj = plot.xaxis[0] + elif axis == 'y': + axis_obj = plot.yaxis[0] + + if isinstance(axis_obj, CategoricalAxis): + for key in list(axis_props): + if key.startswith('major_label'): + new_key = key.replace('major_label', 'group') + axis_props[new_key] = axis_props[key] return axis_props @@ -500,10 +491,12 @@ def _update_plot(self, key, plot, element=None): props = {axis: self._axis_properties(axis, key, plot, dim) 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 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', {}))