verisimilidude
verisimilidude

Reputation: 475

Problems creating a categorical histogram in Bokeh and Pandas

I am trying to produce a simple histogram of categorical data with the following code

import pandas as pd
from bokeh.plotting import figure, show

# some fake categories and count data
counts = pd.Series({'Cat0':1599, 'Cat1':1357, 'Cat2':671, 
                    'Cat3':610, 'Cat4':446, 'Cat5':210})

# pull out the categories from the index
cats = list(counts.keys())

plt = figure(x_range=cats)
plt.vbar(cats, top=list(counts.values), width=2, line_color='green')
show(plt)

but instead of a plot I get

Javascript error adding output! Error: Error rendering Bokeh model: could not find tag with id: e7346df5-7d3d-4f34-92e2-9e59eb36ec41 See your browser Javascript console for more details.

Is this a bug or have I specified something wrong?

I am using Firefox 54.0 running on Ubuntu (kernel 4.10.0). Other Bokeh plots run without a problem. I am outputting them inline to a Jupyter notebook. Bokeh is bokeh-0.12.4-py3.6.

Upvotes: 0

Views: 448

Answers (1)

verisimilidude
verisimilidude

Reputation: 475

Not sure what is causing the problem, but re-executing

from bokeh.plotting import figure, show, output_notebook

and re-running

output_notebook()

solves the problem and plots again show in the notebook.

Upvotes: 0

Related Questions