Plotly: Change transparency of fillcolor
22,572
Solution 1
You would need to use rgba
to specify the alpha channel as well, rgb
ignores the transparency.
import plotly
trace = plotly.graph_objs.Scatter(x=[30,45],y=[3000,3000],
fill='tozeroy',
fillcolor='rgba(26,150,65,0.5)',
mode='none')
plotly.offline.iplot(plotly.graph_objs.Figure(data=[trace]))
Solution 2
Looks like there is for traces. opacity=0.5
is an argument. https://plotly.com/python/marker-style/
Author by
Hans Bambel
Updated on July 14, 2022Comments
-
Hans Bambel almost 2 years
I'm trying to change the default color of a fillcolor in Plotly to another transparent one, but when I change the fillcolor it is not transparent anymore.
trace = (go.Scatter(x=[30,45],y=[3000,3000], fill='tozeroy', # fillcolor='green', # fillcolor='rgb(26,150,65,0.5)', # fillcolor=dict(color='rgb(26,150,65,0.5)'), # fillcolor=dict(marker=dict(color='rgb(26,150,65,0.5)')), opacity=0.1, showlegend=False, hoverinfo='none', mode='none')) py.offline.iplot(go.Figure(data=[trace]))
This default call results in the following:
and when I use
fillcolor='green'
it results in this nontransparent color:The commented code results in the default case again.
-
Jacquot over 3 yearsI cannot propose an edit directly, but it would be a great addition if the title was made more explicit, like : "Plotly scatter plot: Change transparency of fillcolor for filled area"
-
Hans Bambel over 3 yearsI don't think this is explicit to the Scatter plot, or is it? Also a fillcolor is inherently filling an area, right?
-
Jacquot over 3 yearsNo, it isn't. And yes. My comment came from the frustration of searching some time for that post, and adding specific keywords can make for a better search engine indexation.
-
-
mzoll about 5 yearsis there no option to do this by some plot-native key like 'opacity=0.3' or something, rather than to manipulate the color object/directive
-
Quint almost 3 years@mzoll Looks like there is for traces
opacity=0.5
is an argument. plotly.com/python/marker-style