Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Plotly Cloropleth Map has Holes in Certain States

I am looking to plot a map of state, value pairings using the cloropleth function in plotly.express library and for some reason I am seeing holes in the maps. enter image description here

As you can see, there is a hole in Florida and in Utah, and I can’t figure out how to remove them. My code is as follows where state is just the two letter code for a state:

import plotly.express as px
fig = px.choropleth(df,
                    locations='state', 
                    locationmode="USA-states", 
                    scope="usa",
                    color='value',
                    color_continuous_scale="darkmint", 
                    title='Map'
                    )

There are no missing values in my data so this is an issue with plotly. Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Those holes aren’t going anywhere since they are in fact Great Salt Lake and Lake Okeechobe. But you can ignore them in your map with:

fig.update_layout(geo = dict(showlakes=False))

Plot

enter image description here

Complete code:

import plotly.express as px

fig = px.choropleth(locations=["CA", "TX", "NY"], locationmode="USA-states", color=[1,2,3], scope="usa")
fig.update_layout(geo = dict(showlakes=False))
fig.show()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading