Open
Description
Coming from plotly.py. Since this is about the plotly.graph_objects
module, the issue is posted here.
Currently, only plotly.graph_objects.Scatter.marker
, plotly.graph_objects.Scatter.marker.gradient
and plotly.graph_objects.Scatter.marker.line
supports assigning colors by arrays of color
along with colorscale
.
Could the same color-setting techniques be allowed for plotly.graph_objects.Scatter.line
and plotly.graph_objects.Scatter.fillcolor
as well?
p.s. Links to the current documentation:
- The following supports arrays of color with
colorscale
:
- The following doesn't support arrays of color with
colorscale
:
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
nicolaskruchten commentedon Nov 10, 2020
These are both good ideas although a bit trickier to implement because these arrays wouldn't have the same lengths as the others in the trace: the line.color would be 1 element shorter, and the fillcolor one would be different again. I'm actually not clear what kind of plot you'd like to make with variable fillcolor :)
alexcjohnson commentedon Nov 10, 2020
I'm guessing the variable fillcolor would be like https://stackoverflow.com/a/59950664/9188800

The line case is covered in #581 - short answer: big pain in SVG, more manageable in
scattergl
. I'd say the same goes for variablefillcolor
@nicolaskruchten I guess it could either be 1 element shorter or the same length, depending on exactly what you want the color to mean, and whether you want a smooth variation or a single color per segment. There may be use cases for both, and neither is particularly easy in SVG.
jleaves commentedon Nov 22, 2020
Sorry for the late reply.
I was trying to plot shapes with different colors. Each polygon (
plotly.graph_objects.Scatter.fillcolor
) comes with a numeric property which I want to illustrate by the "fill" color. Furthermore, the common boundary of two polygons (plotly.graph_objects.Scatter.line
) also has a numeric property which I want to illustrate (now maybe by "width", but support for "color" may be helpful as well).The simplist graph would look like this:
Currently, I have to write my own "color mapping" function, something like the function
map_z2color
in this section. With regards to my specific application, I successfully work around this issue with the above method.But still, I guess my naive method may have performance issues as I have to manually produce a string of color for every polygon and every boundary. So maybe the "feature request" is still a good improvement? Any suggestions?
ryani commentedon Dec 21, 2020
I'm also interested in this feature. I'd like the lines to change color via something like the heatmap z component. I'd actually prefer gradient lines (blending between the values at each point) but using the z value of the start or end point would be fine.
My use case is scatter lines representing 2d data over time, and I want the trail to fade out as the points get further in the past.
yotkadata commentedon Aug 15, 2023
It would be really great to be able to use arrays/lists of colors for line and fillcolor. I am currently working on an interactive version of my MeteoHist App and I could've really used this feature. Instead, I ended up adding 365 traces to my Plot - one for every day of the year. This might serve as a workaround for others:
With a bar chart, I could get more or less what I want in one trace (code from inside a class):
But I like much better to draw an area between the mean and the current value. Since I can't use the color array directly, I have to create many "shapes" (actually they are Scatter traces):
In the end this works, but it's quite slower performance-wise and also feels more "hacky".
[-][Feature Request] Support arrays of color and colorscale for line and fillcolor of `plotly.graph_objects.Scatter`[/-][+]support arrays of color and colorscale for line and fillcolor of `plotly.graph_objects.Scatter`[/+]