✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Scatter_geo only shows values with a certain color if I have multiple years as the same year

The code below works fine:

dataVals = {
‘Lat’: [39.783730, 7, 39.783730, 39.783730, 20, -4.03, 39.783730, 36.82, 39.783730],
‘Lon’: [-100.445882, 66, -100.445882, -100.445882, 70, 5.33, -100.445882, -1.29, -100.445882],
‘Value’: [40, 12, 22, 3, 60, 23, 30, 100, 200],
‘Year’: [‘1985’, ‘1990’, ‘1993’, ‘1995’, ‘1996’, ‘1998’, ‘2000’, ‘2001’, ‘2002’],
‘Continent Color’: [“a”, “b”, “a”, “a”, “b”, “c”, “b”, “d”, “a”]
}
data = pd.DataFrame(dataVals)

fig = px.scatter_geo(data, lat=“Lat”, lon=“Lon”, size=“Value”, color=“Continent Color”, animation_frame=“Year”, projection=“natural earth”, size_max=2000)

fig.show()

But if I change some of the years to the same year it doesn’t work:

dataVals = {
‘Lat’: [39.783730, 7, 39.783730, 39.783730, 20, -4.03, 39.783730, 36.82, 39.783730],
‘Lon’: [-100.445882, 66, -100.445882, -100.445882, 70, 5.33, -100.445882, -1.29, -100.445882],
‘Value’: [40, 12, 22, 3, 60, 23, 30, 100, 200],
‘Year’: [‘1985’, ‘1990’, ‘1990’, ‘1990’, ‘1990’, ‘1990’, ‘2000’, ‘2000’, ‘2000’],
‘Continent Color’: [“a”, “b”, “a”, “a”, “b”, “c”, “b”, “d”, “a”]
}
data = pd.DataFrame(dataVals)

fig = px.scatter_geo(data, lat=“Lat”, lon=“Lon”, size=“Value”, color=“Continent Color”, animation_frame=“Year”, projection=“natural earth”, size_max=2000)

fig.show()

In this case it will only show the values that have the Continent Color of “a”

I was able to have multiple years as the same value before I added colors

Any help would be appreciated

Hi @bharrisotcd welcome to the forum! Thank you for the report, this looks like a bug to me. I’ve created https://github.com/plotly/plotly.py/issues/2259, you can subscribe to the issue to get notifications about when this is fixed. In the meantime, the problem disappears when all colors are used in the first frame, you can create dummy points with value 0 in the first frame, they will not visible. It’s a hack and hopefully we’ll have a better solution soon!