I'm following this example from the Plotly documentation but I'm trying to set the color of the confidence region as the same chosen color for the line but with added transparency (alpha), unlike the docs example in which the fill color is defined manually. Is there a way to do it?
Below is an example of what I'm trying to do. In the function defined in the snippet, ideally I would be able to set color in any way acceptable by Plotly (e.g. color="red", or color="rgb(31, 119, 180)") and have alpha added for the fill.
import plotly.graph_objs as go
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/wind_speed_laurel_nebraska.csv')
def gen_plot_ci(x, y, y_lo, y_hi, color):
fig = go.Figure([
go.Scatter(
name='Measurement',
x=x,
y=y,
mode='lines',
line=dict(color=color), # <-- Using the `color` argument for the line
),
go.Scatter(
name='Upper Bound',
x=x,
y=y_hi,
mode='lines',
marker=dict(color="#000"),
line=dict(width=0),
showlegend=False
),
go.Scatter(
name='Lower Bound',
x=x,
y=y_lo,
marker=dict(color="#444"),
line=dict(width=0),
mode='lines',
fillcolor='rgba(68, 68, 68, 0.3)', # <-- Here I'd like to use the `color` argument and just add alpha
fill='tonexty',
showlegend=False
)
])
fig.update_layout(
yaxis_title='Wind speed (m/s)',
title='Continuous, variable value error bars',
hovermode="x"
)
fig.show()
gen_plot_ci(
df['Time'],
df['10 Min Sampled Avg'],
df['10 Min Sampled Avg']-df['10 Min Std Dev'],
df['10 Min Sampled Avg']+df['10 Min Std Dev'],
color='rgb(31, 119, 180)',
)

color="#444"again but with added transparency?color="#444", that's related to the marker and will not be displayed because of the zero line width (line=dict(width=0)). I'd like to use the color passed in thecolorargument from my functiongen_plot_ci(), but with added alpha