Pie chart woes, help!

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:

https://bokeh.pydata.org/en/latest/docs/gallery/pie_chart.html

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§

``

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:

  1. Tooltips are not being displayed when I hover over a section. I see “origin” and I see “count” but not their values. Why?

  2. 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

I’d like to just apologize for the sloppy formatting in the last post. Bad/copy paste.

Anyway, hopefully my questions are still clear.

Thanks!

-aps

···

On Monday, November 26, 2018 at 3:12:08 PM UTC-5, pisymbol wrote:

First off, love me some bokeh but I am struggling with a few simple things.

Well, it turns out JupyterLab with the new dark theme is the source of the issue? Is this a known bug? If I use just Jupyter or the default “white” theme under JupyterLab everything (tooltips) just work.

Any takers on question 2? Is that a p.text thing? I’m still trying to find an example.

-aps

···

On Monday, November 26, 2018 at 3:12:08 PM UTC-5, pisymbol wrote:

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:

https://bokeh.pydata.org/en/latest/docs/gallery/pie_chart.html

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§

``

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:

  1. Tooltips are not being displayed when I hover over a section. I see “origin” and I see “count” but not their values. Why?
  1. How do I display the percentages on top of the pie chart if I so choose?

Hi,

For the JLab question: no idea really, it's possible JLab introduced some breaking change. If this can be made into a complete minimal reproducer, a GH issue is a reasonable next step.

For question 2 you probably want to use Label or LabelSet to label the wedges:

  https://bokeh.pydata.org/en/latest/docs/user_guide/annotations.html#labels

Either way you'll probably need to compute the locations for the labels yourself, for now. Ideally the glyph could expose various computed anchor coordinates that could drive LabelSet directly, but this is not yet possible.

Thanks,

Bryan

···

On Nov 26, 2018, at 12:59, pisymbol <[email protected]> wrote:

On Monday, November 26, 2018 at 3:12:08 PM UTC-5, pisymbol wrote:
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:

https://bokeh.pydata.org/en/latest/docs/gallery/pie_chart.html

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:

1) Tooltips are not being displayed when I hover over a section. I see "origin" and I see "count" but not their values. Why?

2) How do I display the percentages on top of the pie chart if I so choose?

Well, it turns out JupyterLab with the new dark theme is the source of the issue? Is this a known bug? If I use just Jupyter or the default "white" theme under JupyterLab everything (tooltips) just work.

Any takers on question 2? Is that a p.text thing? I'm still trying to find an example.

-aps

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9ab7cc0a-e1e4-47e7-a782-a2c972d259c7%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

For the JLab question: no idea really, it’s possible JLab introduced some breaking change. If this can be made into a complete minimal reproducer, a GH issue is a reasonable next step.

For question 2 you probably want to use Label or LabelSet to label the wedges:

    [https://bokeh.pydata.org/en/latest/docs/user_guide/annotations.html#labels](https://bokeh.pydata.org/en/latest/docs/user_guide/annotations.html#labels)

Either way you’ll probably need to compute the locations for the labels yourself, for now. Ideally the glyph could expose various computed anchor coordinates that could drive LabelSet directly, but this is not yet possible.

That is a big bummer. But OK, that is doable. Thanks for letting me know.

-aps

···

On Monday, November 26, 2018 at 5:55:49 PM UTC-5, Bryan Van de ven wrote: