Changing Line from Solid to Dashed after Certain Number

Hi @nymosis,

You won’t be able to change the dash style within a single trace, but you should be able to do this with two separate traces.

Here’s a starting point for you

import pandas as pd

gdp = pd.DataFrame({'Year': [1990, 1991, 1992, 1993, 1994], 'Ukraine': [5, 4, 7, 4, 6]})
gdp1 = gdp.loc[gdp.Year <= 1992]
gdp2 = gdp.loc[gdp.Year >= 1992]

fig = go.FigureWidget(data=[
    go.Scatter(x=gdp1.Year, y=gdp1.Ukraine, mode='lines', line={'dash': 'solid', 'color': 'green'}),
    go.Scatter(x=gdp2.Year, y=gdp2.Ukraine, mode='lines', line={'dash': 'dash', 'color': 'green'}),
])
fig

Hope that helps!
-Jon

2 Likes