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 e84d17c
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions holoviews/plotting/bokeh/element.py
Expand Up @@ -19,10 +19,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 +402,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 +467,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 +492,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 e84d17c

Please sign in to comment.