Created
November 6, 2020 22:08
-
-
Save brinnaebent/ac2ad5cec6230667d805227e811c5998 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.patches import Polygon | |
fig = plt.figure(figsize=(20,10)) | |
plt.rcParams.update({'font.size': 20}) | |
usmap = Basemap(llcrnrlon=-121,llcrnrlat=20,urcrnrlon=-62,urcrnrlat=51, projection='lcc',lat_1=32,lat_2=45,lon_0=-95) | |
usmap.readshapefile('st99_d00', name='states', drawbounds=True) | |
ax = plt.gca() | |
for i, shapedict in enumerate(usmap.states_info): | |
if shapedict['NAME'] in ['Alaska', 'Hawaii']: | |
seg = usmap.states[int(shapedict['SHAPENUM'] - 1)] | |
if shapedict['NAME'] == 'Hawaii': | |
seg = list(map(lambda seg: (seg[0] + 5200000, seg[1]-1400000), seg)) | |
elif shapedict['NAME'] == 'Alaska': | |
seg = list(map(lambda seg: (0.35*seg[0] + 1100000, 0.35*seg[1]-1300000), seg)) | |
poly = Polygon(seg, facecolor='white', edgecolor='black', linewidth=.5) | |
ax.add_patch(poly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment