The error in your code was that you were setting the mode
to lines+markers
, which is an invalid property in a line chart. The code that worked looks like this:
import plotly.express as px# datadf = px.data.gapminder()df = df[df['country'].isin(['Canada', 'USA', 'Norway', 'Sweden', 'Germany'])]# plotlyfig = px.line(df, x='year', y='lifeExp',color='country')fig.update_traces(patch={"line": {"color": "black", "width": 4}})fig.update_traces(patch={"line": {"color": "black", "width": 4, "dash": 'dot'}}, selector={"legendgroup": "Canada"}) fig.show()
And returned a graph like this: