bokeh icon indicating copy to clipboard operation
bokeh copied to clipboard

[FEATURE] Emit warning when data too large to render as image

Open droumis opened this issue 1 year ago • 5 comments
trafficstars

Problem description

Currently, if trying to plot an image from an array that is beyond a certain size, Bokeh will just display an empty plot. This can be confusing.

Feature description

Consider emitting a warning when dataset is too large to plot.

Potential alternatives

None

Additional information

from bokeh.plotting import figure, show
from bokeh.io import output_notebook
from bokeh.layouts import row
import numpy as np
output_notebook()

data1 = np.random.rand(2, 60000)
data2 = np.random.rand(2, 70000)
data3 = np.random.rand(1, 70000)

p1 = figure(width=300, height=150)
p2 = figure(width=300, height=150)
p3 = figure(width=300, height=150)

p1.image(image=[data1], x=0, y=0, dw=2, dh=60000)
p2.image(image=[data2], x=0, y=0, dw=2, dh=70000)
p3.image(image=[data3], x=0, y=0, dw=1, dh=70000)

show(row(p1, p2, p3))

image

droumis avatar Jan 09 '24 20:01 droumis

Consider emitting a warning when dataset is too large to plot.

Do you mean in Python? How could we know ahead of time? I expect this limitation is depends on browser version, OS, and possibly other issues. E.g. all of the above render fine on Safari for me:

Screenshot 2024-01-09 at 12 36 39

Are there any console errors in your browser? I expect JS console message is the best we can do here.

bryevdv avatar Jan 09 '24 20:01 bryevdv

ah, interesting. I didn't expect that. It works in Safari for me as well but not Chrome. I don't see any errors in the Chrome console. I think a message there would be sufficient.

droumis avatar Jan 09 '24 21:01 droumis

It really depends on the browser and its config. Additionally browsers can either reach these limits silently like Chromium does or fail hard like Firefox does, e.g.: image

and at a much lower threshold than Chromium.

mattpap avatar Jan 09 '24 22:01 mattpap

I will mark this as a discussion for the time being, but I strongly doubt we can do anything in general here.

mattpap avatar Jan 09 '24 22:01 mattpap

sounds good. thanks for investigating! Maybe a note in the documentation would be a sufficient step for the short term.

droumis avatar Jan 10 '24 01:01 droumis