Not sure what happened but my color scale ‘broke’ without me changing any of the code… maybe due to a module update… Now I can’t get any custom color scale to work nor any Plotly built-in scale, like ‘hot’. This is what was working for a long time, live now at http://www.policekillings.info.
scale_colors=[ “rgb(255,255,255)”, “rgb(254,178,76)”, “rgb(252,78,42)”, “rgb(189,0,38)”, “rgb(189,0,38)”,
“rgb(189,0,38)”,“rgb(189,0,38)”,“rgb(128,0,38)”, “rgb(128,0,38)”]
…
color_continuous_scale=scale_colors,
…
But now my map is not using my color scale and is instead falling back to the default Plotly blue, purple, orange, yellow scale. So, color_continuous_scale setting is entirely being ignored for some reason.
Any ideas appreciated!
Full figure settings for reference:
fig = px.choropleth(
data_frame=df,
locationmode=‘USA-states’,
locations=‘StateCode’,
scope=“usa”,
color=per_million,
range_color=(0,199), # This keeps the color key consistent between different race data
color_continuous_scale=scale_colors,
template=‘plotly_dark’,
hover_name=‘State’
)
fig.update_layout(
yaxis={‘automargin’:True,},
xaxis={‘automargin’:True},
geo=dict(bgcolor=‘#202b38’, lakecolor=‘#4E5D6C’),
paper_bgcolor=‘#202b38’,
plot_bgcolor=‘#202b38’,
width=920,
height=500,
dragmode=False,
hoverlabel=dict(
font_size=16,
bgcolor=‘#202b38’,
bordercolor=‘#FFFFFF’,
align=‘left’,
font_color=‘white’
),
coloraxis_colorbar=dict(
title=“Number of People
Killed Per Million”,
titleside=‘top’,
thicknessmode=“pixels”, thickness=30,
lenmode=“pixels”, len=300,
yanchor=“bottom”, y=0.27,
xanchor=“left”, x=-0.05,
),
)