Hi @vedantroy welcome to the forums.
I did not fully understand what you want to do. Instead of using dark24 you want to use viridis? The question is, how do you want to use it, here are three options (I added dark24 for clarity reasons):
code:
from plotly.express.colors import sample_colorscale
from sklearn.preprocessing import minmax_scale
import plotly.graph_objects as go
import itertools as it
import numpy as np
# create data
x = np.ones(24)
y = np.arange(0,24)
cycled = it.cycle(plotly.colors.sequential.Viridis)
cycled_viridis24 = [next(cycled) for _ in y]
discrete_viridis24 = sample_colorscale('Viridis', minmax_scale(y))
# ^^ you could do the min/max scaling wthout sklearn:
# y_scaled = [(val - y.min()) / (y.max() - y.min()) for val in y]
# discrete_viridis24 = sample_colorscale('Viridis', y_scaled)
fig = go.Figure()
fig.add_scatter(x=x, y=y, mode='markers', marker={'size':10, 'size':10, 'color': y, 'colorscale': 'Viridis'}, name='sequential viridis')
fig.add_scatter(x=x*2, y=y, mode='markers', marker={'size':10, 'color': plotly.colors.qualitative.Dark24}, name='qualitative dark24')
fig.add_scatter(x=x*3, y=y, mode='markers', marker={'size':10, 'color': cycled_viridis24}, name='cycled viridis')
fig.add_scatter(x=x*4, y=y, mode='markers', marker={'size':10, 'color': discrete_viridis24}, name='discrete viridis')
fig.update_layout(width=600, height=500)
This is also a really interesting if you want to create a discrete colorscale from a continous colorscale:
mrep colorscale