Skip to content

Instantly share code, notes, and snippets.

@sdtaylor
Created March 12, 2019 17:15
Show Gist options
  • Save sdtaylor/31ad072cb2ce396c777f2e5259d8c67c to your computer and use it in GitHub Desktop.
Save sdtaylor/31ad072cb2ce396c777f2e5259d8c67c to your computer and use it in GitHub Desktop.
Straightforward USA map with lat/lon grid.
library(tidyverse)
basemap = map_data('state')
lat_range = c(20,60)
lon_range = c(-150,50)
ggplot() +
geom_polygon(data = basemap, aes(x=long, y = lat, group = group), fill=NA, color='black', size=1.5) +
scale_x_continuous(breaks=seq(lon_range[1],lon_range[2],10), minor_breaks = seq(lon_range[1],lon_range[2],1)) +
scale_y_continuous(breaks=seq(lat_range[1],lat_range[2],10), minor_breaks = seq(lat_range[1],lat_range[2],1)) +
theme_bw() +
coord_fixed(1.3) +
theme(panel.background = element_rect(fill='white'),
panel.grid.major = element_line(color='#0072B2', size=1),
panel.grid.minor = element_line(color='#56B4E9', size=0.3),
axis.text = element_text(size=25),
axis.title = element_text(size=30)) +
labs(x='Longitude',y='Latitude')
@sdtaylor
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment