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.
Marker Opacity To maximise visibility of density, it is recommended to set the opacity inside the marker marker:{opacity:0.5} . If multiple traces exist with high density, consider using marker opacity in conjunction with trace opacity.
Plotly Express Set Transparent Color To create a transparent background, we can use the update_layout() function and bass the plot_bgcolor and paper_bgcolor transparent values.
There should be a legend next to the graph with points with all the colors from the df , and whenever a color x clicked, the respective coloring of row x is applied (that is, marker_color becomes df[x] ).
Adding Traces New traces can be added to a plot_ly figure using the add_trace() method. This method accepts a plot_ly figure trace and adds it to the figure. This allows you to start with an empty figure, and add traces to it sequentially.
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]))
Looks like there is for traces. opacity=0.5
is an argument. https://plotly.com/python/marker-style/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With