holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.7k stars 401 forks source link

Bokeh theme precedence different from pure bokeh #3816

Open poplarShift opened 5 years ago

poplarShift commented 5 years ago

Apparently, in bokeh, CategoricalAxis seems to override Axis, but in holoviews, it's the other way around... (I think the pure bokeh way makes much more sense, more specific options overriding the general ones.)

from bokeh.themes import Theme

theme = Theme(json={
'attrs' : {
    'Axis' : {
        'major_tick_out': 0,
    },
    'CategoricalAxis' : {
        'major_tick_out': 25,
    },
}})

# pure bokeh plot

from bokeh.io import show as bshow, output_notebook, curdoc
from bokeh.plotting import figure

output_notebook()

fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']

p = figure(x_range=fruits, plot_height=250, title="Fruit Counts")
p.vbar(x=fruits, top=[5, 3, 4, 2, 4, 6], width=0.9)
curdoc().theme = theme

bshow(p)

# holoviews equivalent with same theme

import holoviews as hv
hv.extension('bokeh')
hv.renderer('bokeh').theme = theme

l = hv.Bars((['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'], [5, 3, 4, 2, 4, 6])).opts(width=500)
p = hv.render(l)
bshow(p)

poplarShift commented 5 years ago

Apparently, when mixing the two, even when setting curdoc().theme it is overriden by hv.renderer('bokeh').theme:

import holoviews as hv
hv.extension('bokeh')
hv.renderer('bokeh').theme = theme
curdoc().theme = theme

l = hv.Bars((['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'], [5, 3, 4, 2, 4, 6])).opts(width=500)
p = hv.render(l)
bshow(p)