1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
include geoplot.gfn
open us-states.geojson --quiet --frompkg=geoplot
bundle b = bread($mapfile)
# Shrink Alaska and place underneath the "lower 48"
matrix shift = {34, -35}
matrix center = {-150.885, 62.5503}
matrix scale = {0.3, 0.35}
geoplot_translate_feature(&b, 48, shift, center, scale)
# Shift Hawaii alongside Alaska
shift = {51, 5}
geoplot_translate_feature(&b, 5, shift)
bwrite(b, "us-rearranged.geojson")
open us-rearranged.geojson
# Add per-state Democratic-win dummy
strings dem_states = defarray("WA", "OR", "CA", "NV", "AZ", "NM",
"CO", "MN", "WI", "IL", "MI", "GA", "VA", "PA", "NY", "VT", "NH",
"ME", "MA", "RI", "CT", "NJ", "DE", "MD", "DC", "HI")
series D = 0
loop i=1..$nobs
if nelem(instrings(dem_states, iso_3166_2[i] + 3))
D[i] = 1
endif
endloop
# Display electoral map
bundle opts = _(plotfile = "us0.plt", title = "USA, 2020")
opts.palette = "set palette maxcolors 2; \
set palette defined (0 '#D22532', 1 '#244999'); unset colorbox"
opts.projection = "EPSG2163"
geoplot($mapfile, D, opts)
|