If you don't mind rgb colors, then n_colors
is one way to go. Here's an example of 15 colors in a gray scale between 'rgb(0, 0, 0)'
and 'rgb(255, 255, 255)'
:
n_colors('rgb(0, 0, 0)', 'rgb(255, 255, 255)', 15, colortype='rgb')
And here's an example of 25 colors between blue 'rgb(0, 0, 255)'
and red , 'rgb(255, 0, 0)'
:
n_colors('rgb(0, 0, 255)', 'rgb(255, 0, 0)', 25, colortype = 'rgb')
Complete code:
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
import datetime
from plotly.colors import n_colors
pd.set_option('display.max_rows', None)
pd.options.plotting.backend = "plotly"
# greys15 = n_colors('rgb(0, 0, 0)', 'rgb(255, 255, 255)', 15, colortype='rgb')
redVSblue = n_colors('rgb(0, 0, 255)', 'rgb(255, 0, 0)', 25, colortype = 'rgb')
fig = go.Figure()
# for i, c in enumerate(greys15):
for i, c in enumerate(redVSblue):
fig.add_bar(x=[i], y = [i+1], marker_color = c, showlegend = False)
f = fig.full_figure_for_development(warn=False)
fig.show()
px.colors.sequential.Plasma_r[:5]
– Huddlecolor_dicreate_map()
to specify more than 10 colors. Another approach would be to use seaborn's color palette to specify the desired number of colors.colors=set_palette("Reds", 24)
– Huddlecolor_discrete_map
and that's not option. – Stranger