change line opacity, leave markers opaque
See original GitHub issueIs it possible to add an opacity to the line-attribute?change the line opacity but not the marker opacity?
I found that I can set the opacity of the entire line including markers (opacity = .5
) and the one of the marker (e.g. marker={"opacity":1}
). However, it is seemingly impossible to reduce the opacity of just the line.
As shown in this example:
import plotly
import plotly.graph_objs as go
plotly.offline.init_notebook_mode(connected=True) # I'm running in a jupyter notebook
x = np.arange(0,10)
ys = [np.random.rand(10) for _ in range(3)]
lines = []
for y in ys:
line = go.Scatter(x=x, y=y, mode="markers+lines", opacity=.5, marker={'symbol': 'x', 'size': "15", "opacity":1},
line={'opacity': 0.5}
)
lines.append(line)
fig = go.Figure(
data=lines,
layout=go.Layout(showlegend=True)
)
plotly.offline.iplot(fig)
See result here:
My problem is the following: My data points are important, the lines are just visual aid. I want to make the lines .5-opaque but have the markers fully opaque.
However, when I set opacity=.5, marker={'opacity':1}
the opacity of the marker is also reduced. (I believe that the marker-opacity is defined in the range [0, line-opacity]
.
PS: If there is an existing solution/workaround for this issue, it might be interesting to (also) answer on my post on Stackoverflow
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:10 (2 by maintainers)
Top GitHub Comments
I have the same use-case. Any plan to address the original issue (adding line.opacity)?
+3
My use case is the bottom right chart here https://covid-19-raffg.herokuapp.com/
Workaround is this: