'Plotly - color cycle setting from a colormap

For matplotlib, I used this code to change a default color cycle setting, so that I could plot multiple lines with colors in this cycle.


n = 24
color = plt.cm.viridis(np.linspace(0, 1,n))
mpl.rcParams['axes.prop_cycle'] = cycler.cycler('color', color) 

for i in range(30):
    plt.plot(x,y,data[data["col1"]==i]) 
plt.show()

How can I do this for plotly as well?

fig = px.line(data[data["col1"]==i],x,y)

for i in range(30):
    fig.add_scatter(x,y,data[data["col1"]==i],mode="line") 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source