Empty plot by Bokeh Bar-chart

I am trying to have an interactive panel, to make possible the presentation of bar charts based on the selection of an independent variable. However, my code returns empty plot, and selecting different items does not update the plot.

I also posted this question on Stackoverflow, which can be found here

@cj9170 You are using categorical data on the X-Axis so you have to make the figure’s x_range be categorical as well.

Change

p = figure( plot_height = 300, title = "Inustry_code", tools=TOOLS)

to

p = figure( plot_height = 300, title = "Inustry_code", x_range=['M1', 'M2', 'M3'], tools=TOOLS)

and your plot will be properly displayed; you will probably have to manually adjust the x_range though.

More information: Handling categorical data — Bokeh 2.3.1 Documentation

PS: consider putting the link of this discourse thread to your SO post

1 Like