Ilmari Kumpula
Ilmari Kumpula

Reputation: 1465

Bokeh doesn't find Bar-chart modules on Raspberry Pi

_I'm trying to make bar-charts with Bokeh to be outputted as .html-files. Everything works fine with simple plotting, but for some reason when i try to run the following code:

from bokeh.charts import Bar, output_file, show
from bokeh.sampledata.autompg import autompg as df

p = Bar(df, label='yr', values='mpg', agg='mean',
    title="Average MPG by YR")

output_file("bar.html")_

I end up with an error saying:

ImportError: No module named 'bokeh.charts'

I have installed Pandas, Numpy through pip and they all can be found using the help('modules') command. I've understood that Pandas is required for high-level Bokeh charts and it's been installed through Pip

Pandas version: 0.20.3 Bokeh version: 0.12.9 Python is version 3.4.2

I've tried also different import commands, "from bokeh import *" etc. but nothing seems to work.

Upvotes: 1

Views: 1562

Answers (2)

Alex
Alex

Reputation: 579

bokeh.charts has been deprecated. You can get back the functionality by installing and importing the bkcharts package but this won’t be supported in the future. Bokeh devs recommend checking holoviews (which use bokeh as a possible back-end)

Upvotes: 0

bigreddot
bigreddot

Reputation: 34568

In addition to Holoviews, if you just need simple bar charts, these are also now easy to make from the stable bokeh.plotting API, e.g.:

group = df.groupby('cyl')
source = ColumnDataSource(group)

cyl_cmap = factor_cmap('cyl', palette=Spectral5, factors=sorted(df.cyl.unique()))

p = figure(plot_height=350, x_range=group, title="MPG by # Cylinders")

p.vbar(x='cyl', top='mpg_mean', width=1, source=source,
       line_color=cyl_cmap, fill_color=cyl_cmap)

enter image description here

Upvotes: 1

Related Questions