@@ -108,57 +108,3 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
108
108
df [names(names )] <- vec_slice(names , df $ group )
109
109
vec_slice(df , stats :: complete.cases(df $ lat , df $ long ))
110
110
}
111
-
112
- # ' Create a layer of map borders
113
- # '
114
- # ' This is a quick and dirty way to get map data (from the \pkg{maps} package)
115
- # ' onto your plot. This is a good place to start if you need some crude
116
- # ' reference lines, but you'll typically want something more sophisticated
117
- # ' for communication graphics.
118
- # '
119
- # ' @param database map data, see [maps::map()] for details
120
- # ' @param regions map region
121
- # ' @param fill fill colour
122
- # ' @param colour border colour
123
- # ' @param xlim,ylim latitudinal and longitudinal ranges for extracting map
124
- # ' polygons, see [maps::map()] for details.
125
- # ' @inheritDotParams geom_polygon
126
- # ' @export
127
- # ' @examples
128
- # ' if (require("maps")) {
129
- # '
130
- # ' ia <- map_data("county", "iowa")
131
- # ' mid_range <- function(x) mean(range(x))
132
- # ' seats <- do.call(rbind, lapply(split(ia, ia$subregion), function(d) {
133
- # ' data.frame(lat = mid_range(d$lat), long = mid_range(d$long), subregion = unique(d$subregion))
134
- # ' }))
135
- # '
136
- # ' ggplot(ia, aes(long, lat)) +
137
- # ' geom_polygon(aes(group = group), fill = NA, colour = "grey60") +
138
- # ' geom_text(aes(label = subregion), data = seats, size = 2, angle = 45)
139
- # ' }
140
- # '
141
- # ' if (require("maps")) {
142
- # ' data(us.cities)
143
- # ' capitals <- subset(us.cities, capital == 2)
144
- # ' ggplot(capitals, aes(long, lat)) +
145
- # ' borders("state") +
146
- # ' geom_point(aes(size = pop)) +
147
- # ' scale_size_area() +
148
- # ' coord_quickmap()
149
- # ' }
150
- # '
151
- # ' if (require("maps")) {
152
- # ' # Same map, with some world context
153
- # ' ggplot(capitals, aes(long, lat)) +
154
- # ' borders("world", xlim = c(-130, -60), ylim = c(20, 50)) +
155
- # ' geom_point(aes(size = pop)) +
156
- # ' scale_size_area() +
157
- # ' coord_quickmap()
158
- # ' }
159
- borders <- function (database = " world" , regions = " ." , fill = NA ,
160
- colour = " grey50" , xlim = NULL , ylim = NULL , ... ) {
161
- df <- map_data(database , regions , xlim = xlim , ylim = ylim )
162
- geom_polygon(aes(.data $ long , .data $ lat , group = .data $ group ), data = df ,
163
- fill = fill , colour = colour , ... , inherit.aes = FALSE )
164
- }
0 commit comments