☰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 identify if a plot is empty

Community Supportbokeh
Isaac_Zhou
Isaac_Zhou

Hi,

I need to plot a procedure which let’s say consist of event1 and event2 when given a pandas Dataframe. But not every time the given Dataframe contains those two events. If the Dataframe contains none of those two events, then bokeh will generate an empty plot which is per-expected.


My question is that how can I identify if a plot is empty before I show it? So that I can avoid show an empty plot to the audience.

⌁   Link to post
gmerritt123
gmerritt123

Something like (just a suggestion because I’m not 100% clear on the conditions)…

Check the dataframe (or even the columndatasource that it’s driving) if it meets your conditions. If it doesn’t, toggle the visibility property of the corresponding figure (e.g. f.visible = False)

⌁   Link to post
Bryan
Bryan

“Empty” needs to be defined much more precisely. Offhand, I can think of many things “plot is empty” might mean:

  • There are no renderers present at all
  • There are renderers but they have no data
  • There are renderers, and they have data but a view is empty
  • There are renderers, and they have data but visible is False.
  • There are “visible” renderers with data but alpha is zero

And others. There’s not any one way to know ahead of time whether a plot will just “appear” empty, so you will have to refine what the actual condition leading to this is in your specific case.

⌁   Link to post

End of archived discussion · Replies are disabled