@@ -74,6 +74,8 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
74
74
# ' @param regions map region
75
75
# ' @param fill fill colour
76
76
# ' @param colour border colour
77
+ # ' @param xlim,ylim latitudinal and logitudinal range for extracting map
78
+ # ' polygons, see \code{\link[maps]{map}} for details.
77
79
# ' @param ... other arguments passed onto \code{\link{geom_polygon}}
78
80
# ' @export
79
81
# ' @examples
@@ -91,11 +93,19 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
91
93
# ' ggplot(capitals, aes(long, lat)) +
92
94
# ' borders("state") +
93
95
# ' geom_point(aes(size = pop)) +
94
- # ' scale_size_area()
96
+ # ' scale_size_area() +
97
+ # ' coord_quickmap()
95
98
# '
99
+ # ' # Same map, with some world context
100
+ # ' ggplot(capitals, aes(long, lat)) +
101
+ # ' borders("world", xlim = c(-130, -60), ylim = c(20, 50)) +
102
+ # ' geom_point(aes(size = pop)) +
103
+ # ' scale_size_area() +
104
+ # ' coord_quickmap()
96
105
# ' }
97
- borders <- function (database = " world" , regions = " ." , fill = NA , colour = " grey50" , ... ) {
98
- df <- map_data(database , regions )
106
+ borders <- function (database = " world" , regions = " ." , fill = NA ,
107
+ colour = " grey50" , xlim = NULL , ylim = NULL , ... ) {
108
+ df <- map_data(database , regions , xlim = xlim , ylim = ylim )
99
109
geom_polygon(aes_(~ long , ~ lat , group = ~ group ), data = df ,
100
110
fill = fill , colour = colour , ... , inherit.aes = FALSE )
101
111
}
0 commit comments