LinearColorMapper for line glyph possible?

I was wondering if it is possible to use a color mapper like LinearColorMapper for a line glyph?
It would be cool to interpolate the color of the line itself between the datapoints according to a given color mapper.

But this is currently not possible, right?

This is not currently possible, and will never be possible. The Line Bokeh glyph maps to the underlying HTML canvas line primitive which can only draw a single color.[1] If you want multiple segments that are different colors, you should user multi_line.

  1. Besides that, there is an additional reason why it can’t work. The connected topology of a line is different from other glyphs. A column of N points only gets you N-1 line segments (between the points), as opposed to a scatter which gets you N scatter points. All the columns of a CDS must always be the same length (i.e. N in this case) which means there are too many colors, you would have to somehow colormap N-1 segments based on N values and that does not work out. ↩︎

Thank you very much for your thorough explanation!

1 Like