I am using some of the new features, and trying to combine Handling Categorical Data — Bokeh 0.12.7 documentation with boolean filters Providing Data for Plots and Tables — Bokeh 0.12.7 documentation
I am changing the visual dodge to have the data all in a column (like one would have to do with altair)
So I am creating a view for each of the three vbar data sets
but it is not working - so my question is - is there a way to view the data in a view to aid in troubleshooting, any ideas on how to further troubleshoot?
Here is the example:
the 2015 data is showing up but not the 2016 and 2017 vbars:
from bokeh.core.properties import value
from bokeh.io import show, output_notebook
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.transform import dodge
from bokeh.models import ColumnDataSource, CDSView, BooleanFilter
output_notebook()
fruits = [‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’]
years = [‘2015’, ‘2016’, ‘2017’]
data = {‘fruits’ :[‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’,
‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’,
‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’],
‘date’: [‘2015’,‘2015’,‘2015’,‘2015’,‘2015’,‘2015’,
‘2016’,‘2016’,‘2016’,‘2016’,‘2016’,‘2016’,
‘2017’, ‘2017’,‘2017’,‘2017’,‘2017’,‘2017’],
‘nums’: [2, 1, 4, 3, 2, 4,
5, 3, 3, 2, 4, 6,
3, 2, 4, 4, 5, 3]
}
source = ColumnDataSource(data=data)
view2015 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2015’ else False for date in source.data[‘date’]])])
view2016 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2016’ else False for date in source.data[‘date’]])])
view2017 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2017’ else False for date in source.data[‘date’]])])
p = figure(x_range=fruits, y_range=(0, 10), plot_height=250, title=“Fruit Counts by Year”,
toolbar_location=None, tools="")
p.vbar(x=dodge(‘fruits’, -0.25, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2015,
color=“green”, legend=value(“2015”))
p.vbar(x=dodge(‘fruits’, 0, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2016,
color=“red”, legend=value(“2016”))
p.vbar(x=dodge(‘fruits’, 0.25, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2017,
color=“blue”, legend=value(“2017”))
p.x_range.range_padding = 0.1
p.xgrid.grid_line_color = None
p.legend.location = “top_left”
p.legend.orientation = “horizontal”
show(p)