Plotly.js: USA-states incorrectly drawn as foreign regions in high resolution choropleth

Created on 17 Apr 2019  Ā·  5Comments  Ā·  Source: plotly/plotly.js

I’ve been working on a choropleth (through plotly.py originally) and things had been going fine at 110 resolution, but I decided to switch to 50 and things got weird. The problem I’m seeing is that I’m providing a list of ā€˜USA-states’ and it’s deciding to map some of them to similarly named world states, e.g. WA (Washington) is mapped on Western Australia and PA (Pennsylvania) is mapped on ParĆ”, Brazil. This problem does not occur at all at the lower 110 resolution where WA is correctly mapped to the USA state as requested.

I’d actually like to take advantage of this hidden feature for other projects but I can only get it to happen through this glitch, not through choice. I’ve tried various other formats like "WA, AUS" or "AUS-WA" and both "USA-states" and "countries" formats. The only thing that causes Western Australia to be drawn is putting ā€œWAā€ and ā€œUSA-statesā€ and resolution=50.

https://jsfiddle.net/Thlayli/3jza9sov/
or
https://plot.ly/~thlayli/22/number-of-artists-by-country-or-region/#/ 1

bug

All 5 comments

Thanks for reporting.

Ha, that's a shame

var gd = document.querySelector('.js-plotly-plot')
gd._fullLayout.geo._subplot.topojson.objects.subunits.geometries.map(g => g.id)

has duplicate ids in it:

image

Looks like we'll have to patch: https://github.com/etpinard/sane-topojson


That said, I wonder if some users out there are using locationmode: 'USA-states to show (incorrectly) Brazil, Australia and Canada sub-divisions?

I'd do it if it was predictable. :D

I'd do it if it was predictable.

Do _what_ exactly? You mean you would use locationmode: 'USA-states' to draw e.g. Brazil sub-division choropleths? That's sounds odd. We should probably add a new locationmode value (e.g. 'subdivisons') for choropleths of the likes.

Yeah, I meant I would plot non-USA regions on a world map if I could specify both country and region code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

archmoj picture archmoj  Ā·  3Comments

boleslawmaliszewski picture boleslawmaliszewski  Ā·  3Comments

pynklu picture pynklu  Ā·  3Comments

danielsamuels picture danielsamuels  Ā·  3Comments

tim-sauchuk picture tim-sauchuk  Ā·  3Comments