Skip to content
Advertisement

How to use Basemap (Python) to plot US with 50 states?

I am aware that the powerful package Basemap can be utilized to plot US map with state boundaries. I have adapted this example from Basemap GitHub repository to plot 48 states colored by their respective population density: enter image description here

Now my question is: Is there a simple way to add Alaska and Hawaii to this map and place those at a custom location, e.g. bottom left corner? Something like this:

enter image description here

JavaScript

Advertisement

Answer

For anyone interested, I was able to fix it myself. The (x,y) coordinates of each segment (for Alaska and Hawaii) should be translated. I also scale down Alaska to 35% before translating it.

The second for-loop should be modified as following:

JavaScript

Here is the new US map (using the ‘Greens’ colormap).

enter image description here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement