I wanted to add vertical bands using Span() to represent weekends in a datetime plot but it seems that the default line_width defaults to ‘screen’ and not ‘data’ as stated in the documents even when explicitly mentioned.
You can reproduce this using the example in the user guide Annotations — Bokeh 3.6.2 Documentation
If you zoom-in the green bands always stay 5 pixels wide.
For my case I would expect the Span width to adjust to the equivalent of 2 days (Saturday + Sunday) using units based on unix timestamp so 2 * 24 * 3600 * 1000
I tried explicitly stating in Span location_units = ‘data’ hoping this would match the relative width of my vbar glyphs which follow the xaxis datetime format and zoom correctly.
Where exactly are you seeing something that states that a span line width can be in data units? That’s not the case, line widths are passed directly to the HTML canvas and are always and only in pixels. I searched the Bokeh docs and none of the places I found said anything about data units for line widths. Please provide an actual URL for what you are looking at.
Span is not the right tool for this job. Lines are generally, more it less, “thin” relative to a plot. I expect browser canvas implementations may even have their own underlying max line width they will render, and Bokeh can’t do anything about that. Fortunately, there are other tools available. For this, I’d say you probably want to look at a BoxAnnotaton which can be as wide as you want, and can also be configured to have unbounded extent across an entire range if desired.
Lastly, please always make sure your MRE code complete, i.e. has all imports and can be copy and pasted and without any changes.