Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Data Visualization with Bokeh Getting and Displaying Data Bokeh's ColumnDataSource

Cody Stephenson
Cody Stephenson
8,361 Points

In case anybody wants to see how to make the vertical bar chart with the current vbar method.

If you want to make the vertical bar anyway using the vbar method I did it this way. It's also a little weird because for vertical bars all the bokeh documentation refers to the y-values as "top" as in the top of the bar, which I think I overly explicit and confusing.

Edit: Updated to include imports and further clarity

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

countries = pd.read_csv(file, nrows=5)

x = countries["Country_English"]
top = countries["Population"]

output_file('population.html')

bar_chart = figure(x_range = x,title = "Vertical Bars Countries pop")

bar_chart.vbar(x=x, top=top)


show(bar_chart)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

Nicely done!

Unfortunately, as the teacher's notes state, the video was based on version 0.12.5 (March 2017) and bokeh.charts has been deprecated.

The latest version is 2.3.2 (May 2021). The replacement for charts is to use bokeh.plotting. Here's the latest doc for vbar().

Edit: updated per Cody's comment below.

Cody Stephenson
Cody Stephenson
8,361 Points

Ah, I should have clarified by including my imports. I think I'm using the current method from bokeh.plotting, but stuck with non-stacked vbar() to make it look as much like the chart from the video as possible.