plotly / plotly/plotly.py

[BUG]: Odd polygon in land layer, extending into Canada on US choropleth

Open
#5,685 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3 size: 3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

Description

There is an odd band extending from the northwest US into Canada when making a US choropleth. You can see this in the official documentation. I think this stems from the GeoJSON file included in Plotly. The file is very out of date, by the way, with changes to Oglala Lakota County in South Dakota and the Kusilvak Census Area in Alaska not being represented.

I can hide this band in the Python version using visible=False when calling update_geos().

Screenshots/Video
Image
Steps to reproduce
Notes

The unemployment example is here for completeness' sake:

from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties = json.load(response)

import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
                   dtype={"fips": str})

import plotly.express as px

fig = px.choropleth(df, geojson=counties, locations='fips', color='unemp',
                           color_continuous_scale="Viridis",
                           range_color=(0, 12),
                           scope="usa",
                           labels={'unemp':'unemployment rate'}
                          )
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the unemployment choropleth example and inspect the referenced geojson-counties-fips.json from the plotly/datasets repository. Compare the northwest geometry and the entries for Oglala Lakota County and Kusilvak Census Area; done means the example no longer shows the band and those county changes are represented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.