☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

How to add legend on the pie chart?

Community Support
Bryan
Bryan

It seems like you must have explicitly set the range start/end to make room for the legends? You will need to adjust that accordingly. Avoiding all this speculation is why it is always important to provide real, actual code for people to examine.

⌁   Link to post
yvechang
yvechang

Thank you for your reminders.

My original codes are,
plot = figure(title=itemInfos, toolbar_location=None, tools=“hover”, tooltips="@countItem: @value", x_range=(-0.5, 1.0))
plot.wedge(x=0, y=1, radius=0.4, start_angle=cumsum(‘angle’, include_zero=True), end_angle=cumsum(‘angle’), direction=‘anticlock’, line_color=“white”, fill_color=‘color’, source=wedgesDataSource[i])
plot.wedge(x=0, y=1, radius=0.4, start_angle=cumsum(‘angle’, include_zero=True), end_angle=cumsum(‘angle’), direction=‘anticlock’, line_color=“white”, fill_color=‘color’, source=wedgesDataSource[i])
…
grid = gridplot(ratioPlot, ncols=columnAmount, sizing_mode=“stretch_both”)

If the first line changed as the following, then the figure looks like …
plot = figure(title=itemInfos, toolbar_location=None, tools=“hover”, tooltips="@countItem: @value", x_range=(-0.6, 0.6), y_range=(-3, 5))

It looks good, but I don’t really understand what is the rule regarding x_range and y_range of the pie chart.

The last figure is changing x_range and y_range like the follows,
plot = figure(title=itemInfos, toolbar_location=None, tools=“hover”, tooltips="@countItem: @value", plot.x_range.range_padding = 0, plot.y_range.range_padding = 0)

⌁   Link to post
Bryan
Bryan

There’s no rule, those are simply the start and end values of the axis. It might help if you temporarily turn axes on the plots so that you can observe how your change to the range values affect the plot.

Also for the future, please always use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)

⌁   Link to post

End of archived discussion · Replies are disabled