Skip to content

"BokehUserWarning: ColumnDataSource's columns must be of the same length" when color mapping Path #6655

@ethanbb

Description

@ethanbb

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc should be added within the dropdown below.)

Software Version Info
python: 3.11
bokeh: 3.7.3
jupyter_bokeh: 4.0.5
matplotlib: 3.10.1
jupyterlab: 4.3.6
OS: Linux
browser: Firefox

Description of expected behavior and the observed behavior

I'm trying to follow the examples from the Geometry Data page, but I'm getting a warning and some inconsistent behavior, as described below. (I also notice the same warning is present in the documentation under each example.)

Complete, minimal, self-contained example code that reproduces the issue

backend = 'bokeh'  # or 'matplotlib'
n_pts = 3 # or 7

import holoviews as hv
hv.extension(backend)
import numpy as np

cell_dim = hv.Dimension(('cell_id', 'CellID'), range=(0, 10), default=5)
c_dim = hv.Dimension(('c', 'Color'), range=(0, 100))

def make_path(n_pts: int):
    p = hv.Path([{'x': np.arange(n_pts) + x, 'y': np.arange(n_pts) + 1, 'c': x * 10} for x in range(5)],
               vdims=c_dim).opts(color='c', cmap='Turbo', colorbar=True)
    return p

make_path(n_pts)

Expected: I see 5 lines (with length depending on n_pts) spanning the lower 40% of the colormap, and the colorbar reflects this.

Actual:

  • bokeh, n_pts = 3: This is the closest. I get the following warning twice: BokehUserWarning: ColumnDataSource's columns must be of the same length. Current lengths: ('color', 9), ('xs', 5), ('ys', 5). The colors of the lines are correct, but the range of the colorbar is wrong:
Image
  • bokeh, n_pts = 7: I get no plot displayed, and the warning BokehUserWarning: ColumnDataSource's columns must be of the same length. Current lengths: ('color', 29), ('xs', 5), ('ys', 5)
  • matplotlib, any n_pts: The plot displays and I don't get any warnings, but there is no colorbar and the lines all have the same color (maybe this is not supported?)
Image

Stack traceback and/or browser JavaScript console output

In the case where the plot didn't show at all, I got this error traceback from Bokeh in the console:

Bokeh traceback Uncaught (in promise) Error: Size mismatch a https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:178 c https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:178 select https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:192 set_data https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:389 set_data https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:385 lazy_initialize https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:385 a https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:222 build_views https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:222 _build_renderers https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:629 build_renderer_views https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:629 lazy_initialize https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:629 a https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:222 build_views https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:222 build_child_views https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:594 lazy_initialize https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:594 a https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:222 build_view https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:222 build_view https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:221 l https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:220 l https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:220 add_document_standalone https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:220 embed_items_notebook https://cdn.bokeh.org/bokeh/release/bokeh-3.7.3.min.js:239 embed_document http://localhost:51485/lab/tree/notebooks line 1 > injectedScript:11 http://localhost:51485/lab/tree/notebooks line 1 > injectedScript:45 http://localhost:51485/lab/tree/notebooks line 1 > injectedScript:67 attachWidget http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 insertWidget http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _insertOutput http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 onModelChanged http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 m http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 l http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 emit http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _onListChanged http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 m http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 l http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 emit http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 push http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _add http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 add http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _onIOPub http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _handleIOPub http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 handleMsg http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _handleMessage http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _msgChain http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 promise callback*45089/b/this._onWSMessage http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 bokeh-3.7.3.min.js:178:190 embed_document http://localhost:51485/lab/tree/notebooks line 1 > injectedScript:11 InterpretGeneratorResume self-hosted:1425 AsyncFunctionThrow self-hosted:804 (Async: async) http://localhost:51485/lab/tree/notebooks line 1 > injectedScript:45 http://localhost:51485/lab/tree/notebooks line 1 > injectedScript:67 attachWidget http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 insertWidget http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _insertOutput http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 onModelChanged http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 m http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 l http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 emit http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _onListChanged http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 m http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 l http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 emit http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 push http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _add http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 add http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _onIOPub http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _handleIOPub http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 AsyncFunctionNext self-hosted:800 (Async: async) handleMsg http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _handleMessage http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 _msgChain http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1 (Async: promise callback) _onWSMessage http://localhost:51485/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1
  • I may be interested in making a pull request to address this

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions