Shift region on a map

shift(map, condition = NULL, shift_by = c(0, 0), set_to = NULL)

Arguments

map

map object as generated by `process_shape` or `ggplot2::map_data`

condition

logical expression describing the subset of the map to use for the scaling

shift_by

numeric vector of length 2. Relative shift in geographic latitude and longitude.

set_to

numeric vector of length 2. Set center of the region (defined by range in lat and long) to this longitude and latitude

Examples

data(states) states %>% shift(DIVISION == "1", shift_by=c(7.5, 0)) %>% shift(DIVISION == "2", shift_by=c(5, 0)) %>% shift(DIVISION == "3", shift_by=c(2.5, 0)) %>% shift(DIVISION == "5", shift_by=c(5, -1.5)) %>% shift(DIVISION == "6", shift_by=c(2.5, -1.5)) %>% shift(DIVISION == "9", shift_by=c(-5, 0)) %>% shift(DIVISION == "8", shift_by=c(-2.5, 0)) %>% shift(DIVISION == "7", shift_by=c(0, -1.5)) %>% filter(lat > 20) %>% ggplot(aes(long, lat)) + geom_polygon(aes(group=group, fill=factor(DIVISION)))
states01 %>% shift(REGION == "4", shift_by=c(-2.5, 0)) %>% shift(REGION == "1", shift_by=c(1.25, 0)) %>% shift(REGION == "3", shift_by=c(0, -1.25)) %>% filter(lat > 20) %>% ggplot(aes(long, lat)) + geom_polygon(aes(group=group, fill=factor(REGION)))
#> Error in eval(lhs, parent, parent): object 'states01' not found