How to efficiently subset a Path or color a Curve

I have a large dataset of some signal over time. In holoviews terminology, I think I would call my data a Chart type. I would like my data to be represented as a line, so just from this, a Curve seems like the most appropriate type.

However, each data point can also be classified as belonging to a discrete state. I would like to have the data colored by this state variable. This has come up before on the forum, but it seems like a Curve can only be a single color. The suggested work around is to use a Path object.

Using a Path solves the coloring issue, but it brings up a new one. The dataset is on the order of a few million points so displaying the whole thing requires something like datashader. However, I do want to be able to see the raw data upon zooming in far enough (using either something like this or maybe a RangeToolLink).

With a Curve I can simply slice the data to the current plot extents and things work fairly quickly. However, it appears that slicing a Path returns the full Path, simply zoomed in on the current region, which is much slower. I assume this is because the Path is not a Chart type and so two points can be out of the current range and still need to be rendered if the line connecting them crosses the plot range.

I have a few ideas of ways to work around this, but I’m not sure how best to do any of them. I could:

  1. Somehow tell the Path to only look at points within the plotting range. I’m not sure if there’s some slick way to do this or if it would require grabbing the raw data and generating a new Path object every time the plotting range changes.
  2. Somehow get coloring to work with Curve objects. I know I could create a new Curve every time the color changes but that seems like it would get very messy quickly.
  3. Something completely different?
1 Like

How are you calling Path? Does this help at all?