☰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

Band behavior & NaN values

Community Support
Maxxner
Maxxner

What is the expected behavior when using a Band when NaN values occur for the lower or upper value? Currently the band seems to collapse into the lower/upper value which is not missing. Naturally I would have expected that Band will not be drawn at all for such a lower/upper value combination. Of course the data can be cleaned upfront however having an option to control this behavior would be great.

import numpy as np
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, DataTable, DateFormatter, TableColumn, Band
from bokeh.plotting import figure

doc = curdoc()

n_rows = 10

data = dict(
        downloads=[np.sin(i)+2 for i in range(n_rows)],
        x=[i for i in range(n_rows)]
    )

data["downloads"][:1] = [np.nan, np.nan]

source = ColumnDataSource(data)

f = figure()
l = f.line(x="x", y="downloads", source=source)
s2_band = Band(base="x", lower=0, upper="downloads", source=source,
               level='underlay', fill_alpha=0.15, fill_color="green")
f.add_layout(s2_band)

doc.add_root(f)

⌁   Link to post
Bryan
Bryan

I expect this is currently undefined behavior. AFAIK the band values are simply added/subtracted from the base series and passed on the HTML canvas APIs to draw fill regions from the results. It’s not really clear what would be useful to do in this case. Neither skipping the point or treating it as a zero value seem generally appropriate.

⌁   Link to post
Bryan
Bryan

I haven’t ever seen any other questions about this. Since there are multiple possible ways to handle things, but not one clear “right” way, it would take some complexity to add this in a configurable way. Until/unless there’s more user interest expressed, I think it’s probably a case where users can best just process their own data to suit their specific needs.

⌁   Link to post

End of archived discussion · Replies are disabled