I'm trying to make the 'Close' line wider than the others using plotly.express. I tried various options with a conditional statement, or adding a trace but nothing seems to work.
fig.for_each_trace(
lambda trace: trace.update(line=dict(color="Black", width=3)) if trace.name == "Close" else ()
This is the code:
import plotly.express as px
ticker = 'TSLA'
colours = ['steelblue', 'tan', 'black', 'red', 'green']
fig = px.line(df.tail(150), x=df.tail(150).index, y=['middle_band', 'SMA_200',
'upper_band', 'lower_band','Close'], title=f'{ticker}',
color_discrete_sequence=colours, width=800, height=600)
fig.update_traces(textfont_size=12, showlegend=True)
fig.update_layout(legend=dict(
yanchor="top",
y=0.9,
xanchor="left",
x=0.02
))
fig.update_xaxes(title_text='Price evolution over time', title_font = {"size": 16},)
fig.update_yaxes(title_text='Price', tickprefix="$")
fig.show()
As always, any help is welcome.