I see - well, I understand the concept, and it’s more or less how I imagined it, but I literally started playing with Plotly a couple days ago and the implementation details of that are a mystery yet to me.
There are two problems I think I need to solve:
How to add another map to the same image? (see code above) Is it a new fig object? Or do I add to the same fig?
The second map would have to show only the US state borders in 1 px width, color=‘white’, and everything else would have to have whatever the rgba code is for transparency (unless there are options to dictate transparency for the other elements).
Any suggestion? It doesn’t have to be syntax-perfect - I’ll figure out the details if I know where to start. I’m honestly a bit lost in the documentation. Thank you!
(Making great progress otherwise, I’ve solved all the other problems thanks to the excellent suggestions I’ve received on this forum, and the map looks great. The only remaining issue is the missing state borders.)
First I defined a choroplethmapbox of cantons. Then from the same geojson file I extracted the LineString(s) representing the boundaries of cantons, and plotted these boundaries as layers associated to the initial figure.
I suppose that you cannot extract the US state boundaries from your geojson file of US counties. Hence you have to find out a geojson file on github or elsewhere, that represent the US states, at the same scale as your initial county geojson file. From the latter file extract, as I did in the above notebook, the US states boundaries, and add them as layers to your initial fig.
It replaces px.choropleth() with px.choropleth_mapbox().
I lose the nice scope="usa" shortcut, which means I lose Alaska and Hawaii. I think it would be hard to bring them back on the map (somehow I would have to render them separately), so I might have to live with that loss (sorry, AK and HI). Unless I could stick scope="usa" back into px.choropleth_mapbox() somehow? Zooming out until AK and HI appear on the map is not an option, the mainland would be too small.
How do I make everything else disappear (without using the magic scope="usa" shortcut)? Canada, Mexico, the oceans, along with several names, are now shown on the map. What are the attributes that control the color for those things? I don’t mind them too much, but I’d like to at least compare the “with” and the “without” versions.