Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Group states and treat them as one piece in map plots

Hi,

is there a way to combine one or more states or countries and treat them as one “piece” in the map?

For instance, I want to group the states NY and CT - group A, color yellow and CA and NV - Group B, color blue. Now i don’t to care about the individual state but about the group. Say I have average temperature for each state, I want only to display each group’s average temperature i.e. Group A average of temperature of NY and CT and Group B average temperature of CA, NV.

Is there a way to group different states or even countries and treat them as one?

Hi @mr.t,

You should assign the same color to the states in a group, and find the lon and lat for an approximate central location in each group.

Define a scattermapbox or a scattergeo with these points representing the central locations, and set the list of strings to be displayed on hover (i.e. the average temperature)
as the value for the key text in these scatter type traces.

@empet thanks, will give it a try and share the code in case someone else has the same q