First off, love me some bokeh but I am struggling with a few simple things.
I am following the example of using “wedge” from here:
Here is my cell’s code in a JupyterLab notebook (bokeh is at 1.0.1/Ubuntu 18.04/docker):
output_notebook()countries[‘angle’] = countries[‘count’]/countries[‘count’].sum() * 2*pi
countries[‘color’] = Inferno256[:len(countries)]
c = ColumnDataSource(countries)
TOOLTIPS = [
(“origin”, ‘@origin’),
(“count”, “@count”),
]
p = figure(plot_height=500, title=“Pie Chart”, tools=“hover”, toolbar_location=None, tooltips=TOOLTIPS)
p.wedge(x=0, y=1, radius=0.75,
start_angle=cumsum(‘angle’, include_zero=True), end_angle=cumsum(‘angle’),
line_color=“white”, fill_color=‘color’, source=c)
p.axis.visible=False
p.grid.grid_line_color = None
show(p)
``
The countries dataframe looks like this:
origin
count
angle
color
0
Afghanistan
1
0.000062
#000003
1
Albania
1
0.000062
#000004
2
Algeria
16
0.000999
#000006
3
Andorra
30
0.001873
#010007
4
Angola
1
0.000062
#010109
Two things:
-
Tooltips are not being displayed when I hover over a section. I see “origin” and I see “count” but not their values. Why?
-
How do I display the percentages on top of the pie chart if I so choose?
Thanks!
-aps
origin
count
angle
color
0
Afghanistan
1
0.000062
#000003
1
Albania
1
0.000062
#000004
2
Algeria
16
0.000999
#000006
3
Andorra
30
0.001873
#010007
4
Angola
1
0.000062
#010109
origin
count
angle
color
0
Afghanistan
1
0.000062
#000003
1
Albania
1
0.000062
#000004
2
Algeria
16
0.000999
#000006
3
Andorra
30
0.001873
#010007
4
Angola
1
0.000062
#010109here…

