Black Lives Matter. Please consider donating to Black Girls Code today.

Question on px.choropleth zmin zmax

Hi this is my first post, I am trying to make an animated COVID-19 choropleth on daily confirmed cases, everythign works fine, but I like to make the scale absolute so that way a few cases in the early days will not make the state look so “red”.

my code is below:

fig = px.choropleth(usa_full, locations=‘State’, title=‘Confirmed Cases In Each State Over time’,

I tried to add zauto zmin zmax in the px.choropleth it gave me error

TypeError: choropleth() got an unexpected keyword argument ‘zauto’

and using something like

fig.update_traces(zauto=False, zmin=0, zmax=400000)

has no effect, no error either.

Also, would be really nice if someone can telle me how to add state abbr on the map, e.g. showing ‘CA’ at california, ‘TX’ at texas.

my plotly version is:

import plotly

Thank you for your time.

When using px.choropleth you’ll want to use the range_color=[<min>,<max>] argument.

The reason fig.update_traces(zauto=False, zmin=0, zmax=400000) isn’t working is that px uses layout.coloraxis rather than per-trace color axes. See for more information :slight_smile:

range_color=[<min>,<max>] works.

Thank you so much !