Color_discrete_sequence for lines

Hi

Please let me know what is my mistake with color_discrete_sequence ?

import plotly.express as px
import pandas as pd

x=[1,2,None,-2,3]
y=[4,5,None,-5,1]
z=[7,8,None,4,2]

df=pd.DataFrame({'x':x,'y':y,'z':z,
                 'color':['1','1','2','3','3'],
                 'colorsec':['frgb(255,0,0)','rgb(255,0,0)','rgb(255,0,0)','rgb(255,0,0)','rgb(255,0,0)']})

fig = px.line_3d(df,x='x', y='y', z='z',color='color',color_discrete_sequence='colorsec',)

fig.show()

Hey @Bijan, a few things in there:

  • For color_discrete_sequence do not pass a dataframe column but rather a list of unique colors. If there are more traces than colors in the list, they will repeat.
  • You have a typo in one of the colors (frgb instead of rgb)

Dear @RenaudLN

Thanks for your contribution. I tried to fix the code according your comments. But still it doesn’t work. Would you fix it and send it. Thanks (Also Thanks for the typo)