Skip to content

Step plot not working with resample_when #1716

@ribas591

Description

@ribas591

ALL software version info

Software Version Info: short
hvplot 0.12.2
python 3.12.12
marimo  0.19.6

firefox
linux
Software Version Info: full
Package            Version
------------------ -----------
anyio              4.12.1
bleach             6.3.0
bokeh              3.8.2
certifi            2026.1.4
charset-normalizer 3.4.4
click              8.3.1
colorcet           3.1.0
contourpy          1.3.3
docutils           0.22.4
h11                0.16.0
holoviews          1.22.1
hvplot             0.12.2
idna               3.11
itsdangerous       2.2.0
jedi               0.19.2
jinja2             3.1.6
linkify-it-py      2.0.3
loro               1.10.3
marimo             0.19.6
markdown           3.10.1
markdown-it-py     4.0.0
markupsafe         3.0.3
mdit-py-plugins    0.5.0
mdurl              0.1.2
msgspec            0.20.0
narwhals           2.15.0
numpy              2.4.1
packaging          26.0
pandas             3.0.0
panel              1.8.6
param              2.3.1
parso              0.8.5
pillow             12.1.0
psutil             7.2.1
pyarrow            23.0.0
pygments           2.19.2
pymdown-extensions 10.20.1
python-dateutil    2.9.0.post0
pyviz-comms        3.0.6
pyyaml             6.0.3
requests           2.32.5
six                1.17.0
starlette          0.52.1
tomlkit            0.14.0
tornado            6.5.4
tqdm               4.67.1
typing-extensions  4.15.0
uc-micro-py        1.0.3
urllib3            2.6.3
uvicorn            0.40.0
webencodings       0.5.1
websockets         16.0
xyzservices        2025.11.0

Description of expected behavior and the observed behavior

Thank you very much for this excellent library!

I am trying to plot a large time series with hvplot. Therefore, I have to use downsampling. I was very happy to find the "resample_when" option, which was just what I needed.
Line plots work well. However, problems arise when I try to use step plots.

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

import hvplot.pandas  # noqa
import pandas as pd

df = pd.read_parquet("https://datasets.holoviz.org/sensor/v1/data.parq")

# works fine
df.hvplot.line(
        x="time",
        y="value",
        downsample=True,
        resample_when=1_000,
)

# also works
df.hvplot.step(
        x="time",
        y="value",
        where="post",
        downsample=True,
)

# error
df.hvplot.step(
        x="time",
        y="value",
        where="post",
        downsample=True,
        resample_when=1_000,
)

Stack traceback and/or browser JavaScript console output

ValueError: negative dimensions are not allowed
Traceback (most recent call last):
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/marimo/_output/formatters/holoviews_formatters.py", line 44, in _show_chart
    return from_panel(plot)._mime_()
           ^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/marimo/_plugins/ui/_impl/from_panel.py", line 285, in __init__
    ref, docs_json, render_json = render_component(self.obj)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/marimo/_plugins/ui/_impl/from_panel.py", line 164, in render_component
    root = obj._render_model(doc, comm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/panel/viewable.py", line 768, in _render_model
    model = self.get_root(doc, comm)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/panel/layout/base.py", line 329, in get_root
    root = super().get_root(doc, comm, preprocess)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/panel/viewable.py", line 698, in get_root
    root = self._get_model(doc, comm=comm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/panel/layout/base.py", line 313, in _get_model
    objects, _ = self._get_objects(model, [], doc, root, comm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/panel/layout/base.py", line 295, in _get_objects
    child = pane._get_model(doc, root, model, comm)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/panel/pane/holoviews.py", line 487, in _get_model
    plot = self._render(doc, comm, root)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/panel/pane/holoviews.py", line 581, in _render
    return renderer.get_plot(self.object, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/renderer.py", line 70, in get_plot
    plot = super().get_plot(obj, doc, renderer, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/renderer.py", line 239, in get_plot
    plot.update(init_key)
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 958, in update
    return self.initialize_plot()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 3474, in initialize_plot
    child = subplot.initialize_plot(ranges, plot, plots)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 2220, in initialize_plot
    self._init_glyphs(plot, element, ranges, source)
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 2120, in _init_glyphs
    data, mapping, style = self.get_data(element, ranges, style)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/chart.py", line 466, in get_data
    element = interpolate_curve(element, interpolation=self.interpolation)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/param/parameterized.py", line 5948, in __new__
    return inst.__call__(*args,**params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/operation.py", line 218, in __call__
    return element.apply(self, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/accessors.py", line 43, in pipelined_call
    result = __call__(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/accessors.py", line 200, in __call__
    new_obj = apply_function(self._obj, **inner_kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/operation.py", line 212, in __call__
    return self._apply(element)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/operation.py", line 141, in _apply
    ret = self._process(element, key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/operation/element.py", line 1142, in _process
    return element.map(self._process_layer, Element)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/data/__init__.py", line 204, in pipelined_fn
    result = method_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/data/__init__.py", line 1316, in map
    return super().map(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/dimension.py", line 761, in map
    return map_fn(self) if applies else self
           ^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/operation/element.py", line 1136, in _process_layer
    xs, dvals = INTERPOLATE_FUNCS[self.p.interpolation](x, dvals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/operation/element.py", line 1110, in pts_to_poststep
    steps = np.zeros(2 * len(x) - 1)
            ^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: negative dimensions are not allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/marimo/_output/formatting.py", line 237, in try_format
    mimetype, data = formatter(obj)
                     ^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/marimo/_output/formatters/holoviews_formatters.py", line 47, in _show_chart
    backend_output = hv.render(plot)
                     ^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/util/__init__.py", line 892, in render
    return renderer_obj.get_plot_state(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/renderer.py", line 273, in get_plot_state
    obj = self_or_cls.get_plot(obj=obj, renderer=renderer, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/renderer.py", line 70, in get_plot
    plot = super().get_plot(obj, doc, renderer, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/renderer.py", line 239, in get_plot
    plot.update(init_key)
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 958, in update
    return self.initialize_plot()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 3474, in initialize_plot
    child = subplot.initialize_plot(ranges, plot, plots)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 2220, in initialize_plot
    self._init_glyphs(plot, element, ranges, source)
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 2120, in _init_glyphs
    data, mapping, style = self.get_data(element, ranges, style)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/plotting/bokeh/chart.py", line 466, in get_data
    element = interpolate_curve(element, interpolation=self.interpolation)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/param/parameterized.py", line 5948, in __new__
    return inst.__call__(*args,**params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/operation.py", line 218, in __call__
    return element.apply(self, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/accessors.py", line 43, in pipelined_call
    result = __call__(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/accessors.py", line 200, in __call__
    new_obj = apply_function(self._obj, **inner_kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/operation.py", line 212, in __call__
    return self._apply(element)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/operation.py", line 141, in _apply
    ret = self._process(element, key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/operation/element.py", line 1142, in _process
    return element.map(self._process_layer, Element)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/data/__init__.py", line 204, in pipelined_fn
    result = method_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/data/__init__.py", line 1316, in map
    return super().map(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/core/dimension.py", line 761, in map
    return map_fn(self) if applies else self
           ^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/operation/element.py", line 1136, in _process_layer
    xs, dvals = INTERPOLATE_FUNCS[self.p.interpolation](x, dvals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ar/Work/hvplot_test/.venv/lib/python3.12/site-packages/holoviews/operation/element.py", line 1110, in pts_to_poststep
    steps = np.zeros(2 * len(x) - 1)
            ^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: negative dimensions are not allowed

Metadata

Metadata

Assignees

No one assigned

    Labels

    TRIAGERequires triage or initial assessment

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions