plotly/mercator-choropleth
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| plotly | warning | none, edit by hand | All versions |
A Mercator or equirectangular projection stretches land far from the equator, so shaded regions near the poles look larger than their data warrants. Use an equal-area projection for a shaded map.
fig = px.choropleth(df, locations="iso_alpha", color="lifeExp", projection="mercator")fig = px.choropleth(df, locations="iso_alpha", color="lifeExp", projection="eckert4")What the rule reports
Section titled “What the rule reports”The rule reports a shaded map drawn on a projection that does not keep areas.
| Setting | Calls |
|---|---|
projection="mercator" or projection="equirectangular" |
px.choropleth |
No projection argument, and no projection set anywhere in the file, so plotly draws equirectangular |
px.choropleth |
How to fix it
Section titled “How to fix it”xpd has no automatic fix, so make the change by hand.
Wilke calls an equal-area projection "a good choice for mapping applications that require
accurate reproduction of areas" (page 165). Monmonier writes that "some projections, called
equivalent or equal-area, allow the mapmaker to preserve areal" relationships, and Brewer that
"maps of point patterns or area densities need equal-area projections for accurate
interpretation". "eckert4" keeps areas for a world map and "albers usa" for the United
States.
The rule reads the projection argument of px.choropleth, and treats a call without one as
equirectangular unless the file sets a projection elsewhere, such as with
fig.update_geos(projection_type=...). A projection on go.Choropleth is measured by
xpd views when it draws the figure.
Questions of the presentation review
Section titled “Questions of the presentation review”The rule reports in code what these questions of the presentation guides (xpd charts, xpd tables, and xpd views) ask of the drawn display.
| Question | Page | Principle | What it asks |
|---|---|---|---|
| equal-area-choropleth | 165 | Use equal-area projections for choropleth maps | Does every choropleth map use an equal-area projection so shaded region areas stay proportional to geographic land area? |
Diagnostic message
Section titled “Diagnostic message”projection=$P stretches land far from the equator, so a shaded region near a pole looks larger than the same region near the equator. Wilke recommends a projection that reproduces areas accurately for maps that compare regions. Use projection="eckert4" for the world or projection="albers usa" for the United States.See all rules in the plotly pack.