-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add easy way to add colour fill with gradient #3026
Comments
I am also trying to find a solution to this problem, I want to understand whether it is possible to do it via |
Appreciate your input. Those in Stackoverflow imply that it's possible but in my opinion the for-loop already says it all that it won't be efficient, more so when the data increases. According to a reply from Plotly, there is currently no 'straight implementation' dedicated to create gradient filled area. #3025 Correct me if wrong, I found that Vegalite in JSON (or Altair in Python counterpart) appears to be the only package that does so in a 'simple and direct implementation'. https://vega.github.io/vega-lite/examples/area_gradient.html However that's Vega, a completely different territory. I still prefer Plotly Python personally. The only thing is to hope that Plotly development covers this particular issue of gradient fill with 'easy and direct implementation'. Convenient declaration - that's the thing. If you have a look at Vega, the block of code for gradient is so simple like x1, y1, color, and etc, all easy and convenient to declare. Hopefully, Plotly can also come up with this feature that is as conveniently good as Vega, or even better. |
I've successfully emulated this effect by using a pseudo-element and a linear-gradient:
Simply change NOTES:
|
Appreciate your input @lukeic. How can I do this similar for achieving gradient in plotly gantt chart, metioned some examples below: https://plotly.com/python/gantt/ As, Instesd of keeping the rgb colors, I wnat to keep the gradient colors. colors = {'Not Started': 'rgb(220, 0, 0)', fig = ff.create_gantt(df, colors=colors, index_col='Resource', show_colorbar=True, Could you please let me know if you have any ideas on achieving this? |
Hi, any updates with the implementation of the background fill? |
Hello, there is any updates with this implementation of the background with gradient? |
There is no update and no one is working on this feature as far as I know. |
I was working on it earlier, and re-implemented using D3.js as plotly was taking huge time to plot it. |
That's so sad, i really wanted do make this effect works on a chart that i'm implementing in a dashboard, but it will lose a lot of quality without the gradiente effect :( |
I've managed to do something. It's a bit tricky and only useful if you render the chart as a html (probably you could do it in a notebook or something too but haven't explored that option) I've created a file called gradients.svg that I import using <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="atr-lg" gradientTransform="rotate(90)">
<stop offset="5%" stop-color="rgba(31,133,214,.5)" />
<stop offset="95%" stop-color="rgba(31,133,214,0.01)" />
</linearGradient>
</defs>
</svg> Then in CSS I got the fill selector for the element I need (in my case it was subplot x4y4) #candles .x4y4 .js-fill {
fill: url(#atr-lg) !important;
} But would be defo nice to be able to use a linear-gradient straight from when the plot is rendered. I know ...
fillcolor="""
<linearGradient gradientTransform="rotate(90)">
<stop offset="5%" stop-color="rgba(31,133,214,.5)" />
<stop offset="95%" stop-color="rgba(31,133,214,0.01)" />
</linearGradient>
"""
... Then plotly can copy the user definition somewhere relevant in the html and it can add some uid as id to reference in the |
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Alternatively, if it's a request for tech support, please post in our community forum. Thank you - @gvwilson |
I still can't add gradient on the graph |
I'm posting this here for my own future reference; It's not clear why this is done via a scatter, but if you're looking for a way to do it here's how: under gradient fill there's an addition from 5.20 In the auto generated docs opacity via rgba instead of rgb is not specified using this:
if you need multiple areas that are not connected you can use your_figure.add_traces() to add them separately from one another:
you can make this (gradient flowing top to bottom with different opacities/colors) |
I've been getting the following error when using the new fillgradient property of go.Scatter in Dash. Simply running the example plot of fillgradient give the following error in dash: ValueError: Invalid property specified for object of type plotly.graph_objs.Scatter: 'fillgradient' Did you mean "fillpattern"?
|
We can set the fill colour using the
fillcolor
parameter which accepts colour names and rgb values. This, however, only allows single colours. Is there an easy way to make gradient colours? Below is what I'm actually trying to achieve:The text was updated successfully, but these errors were encountered: