☰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

Image not displaying

Community Support
bokehcoder
bokehcoder

Hi, I am trying to display an image like this in jupyterlab where i have enabled output_notebook():

from bokeh.layouts import row
from bokeh.io import show, output_notebook
from bokeh.plotting import figure
from utils import imshow
import numpy as np, pandas as pd, json
from skimage.measure import label, regionprops_table
import cv2
from bokeh.plotting import ColumnDataSource
output_notebook()

ds = ColumnDataSource(data=dict(image=[img])) 
p = figure(x_range=(0, img.shape[1]), y_range=(0, img.shape[0]))
p.image(
    image='image', x=0, y=0, 
    dw=img.shape[1], dh=img.shape[0], 
    palette="Spectral11"
)
show(p)

However when i run the cell no image shows and i the following error in the console:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'dimension')
    at p._set_data (bokeh-3.0.3.min.js:509:2147)
    at p.set_data (bokeh-3.0.3.min.js:376:4330)
    at R.set_data (bokeh-3.0.3.min.js:372:4143)
    at R.lazy_initialize (bokeh-3.0.3.min.js:372:1824)
    at async a (bokeh-3.0.3.min.js:224:210)
    at async t.build_views (bokeh-3.0.3.min.js:224:625)
    at async _.build_renderer_views (bokeh-3.0.3.min.js:574:10203)
    at async _.lazy_initialize (bokeh-3.0.3.min.js:574:3853)
    at async a (bokeh-3.0.3.min.js:224:210)
    at async t.build_view (bokeh-3.0.3.min.js:224:315)

If i display the image directly (without using columndatasource) it works great.

Why can i not use columndatasource like this?

⌁   Link to post
bokehcoder
bokehcoder

Here is a complete reproducable example:

from bokeh.plotting import ColumnDataSource
from bokeh.io import show, output_notebook
from bokeh.plotting import figure
from utils import imshow
import numpy as np
output_notebook()
img = np.random.rand(10,10)
ds = ColumnDataSource(data=dict(image=[img])) # image=[np.flipud(img)]
p = figure(x_range=(0, img.shape[1]), y_range=(0, img.shape[0]))
p.image(
    image='image', x=0, y=0, 
    dw=img.shape[1], dh=img.shape[0], 
    palette="Spectral11"
)
show(p)

Im running it in a jupyterlab notebook

⌁   Link to post

End of archived discussion · Replies are disabled