scale.Rd
Scale regions in a map
scale(map, condition = NULL, scale = 1, set_to = NULL)
map | map object as generated by functions such as `process_shape`, `ggplot2::map_data`, or `ggplot2::fortify` |
---|---|
condition | logical expression describing the subset of the map to use for the scaling |
scale | numeric vector of length 2 used to scale the map region in longitude and latitude. Scale factors should be positive (negative values flip region). |
set_to | numeric vector of length 2. Set center of the region (defined by range in lat and long) to this longitude and latitude |
states <- states %>% group_by(group) %>% mutate(bbox = diff(range(long))*diff(range(lat))) states <- states %>% filter(bbox > 0.15) states %>% ggplot(aes(x = long, y = lat)) + geom_path(aes(group = group))#> Warning: no non-missing arguments to min; returning Inf#> Warning: no non-missing arguments to max; returning -Inf#> Error in delta_x - mean(range(submap$long)) + set_to[1]: non-numeric argument to binary operatorinset <- scale(inset, NAME=="Alaska", scale=0.3, set_to=c(-120, 27)) inset %>% ggplot(aes(long, lat)) + geom_path(aes(group=group))inset <- inset %>% filter(lat > 20) inset %>% ggplot(aes(long, lat)) + geom_path(aes(group=group))