Skip to content

Commit

Permalink
Figured out that dictionary was referenced and not copied
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored and philippjfr committed Oct 7, 2018
1 parent 75bef64 commit 836d4ad
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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'])):
Expand Down Expand Up @@ -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

Expand All @@ -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', {}))

Expand Down

0 comments on commit 836d4ad

Please sign in to comment.