How to keep the color bar in a choropleth map consistent with changing data

The scale of the color bar keeps changing in my choropleth map. I donā€™t know how to keep it consistent, which is essential for what Iā€™m trying to accomplish.

This is my code for the layout:

### create the dictionary with the data for the current year
data_one_year = dict(
type=ā€˜choroplethā€™,
locations = countrylist,
autocolorscale = False,
z=temperatures,
locationmode=ā€˜country namesā€™,
colorscale = scl,
colorbar = dict(
title = ā€œTemperatureā€,
tickvals = [0,5,10,15,20],
lenmode = ā€˜pixelsā€™,
)
)
`data_slider.append(data_one_year) # I add the dictionary to the list of dictionaries for the slider

As you can see, the values on the bar to the right of the map are changing from place. How do I prevent this and make them stay in the same place?

@yassin, you can do this with the zmax and zmin parameters. Plotly determines zmax and zmin based on the data provided but you can override this behaviour setting them yourself.

This actually solved the problem, thanks :slight_smile: