Chloropeth Maps - Incorrect Colours

Hi All,

I am using Plotly Express Chloropeth maps to display values on map. The values range from 0 to 5 billion. When I display the map, the colours for each country is different to the color scale (Turbo) I am using.

I have tried finding solution everywhere but do not seem to find a solution.

Can you please help me.

Following is my code:

fig = px.choropleth(testData, locations='locationName', locationmode='country names', 
                    featureidkey="properties.name", color='valueCount', projection='equirectangular', 
                    labels={'locationName': 'Country', 'valueCount': 'Value (in £)'},
                    range_color=[int(minValue), int(maxValue)], color_continuous_scale='Turbo', 
                    hover_data={'valueCount': ':.1f'}) 
 fig.update_layout(hoverlabel=dict(bgcolor="white", font_color='black', 
                                   font_size=12, font_family="Segoe UI"), 
                                   margin={"r":0,"t":0,"l":0,"b":0}, 
                                   coloraxis_colorbar=dict(tickformat='.0f'))
 fig.update_geos(fitbounds="locations", visible=False)

I have cross-checked that all values are numerical for valueCount numerical.

The color data must be integer or float in order to use a colorscale. Can you tell us what the data type is for the valueCount column in your dataframe? I see that in setting your range color you are casting the value as int which tells me that valueCount might be pandas type “object”.

Hope this helps