Permalink
Browse files

Capture set aesthetics for geom map.

Fixes first part of #511
  • Loading branch information...
1 parent 80adf78 commit 75e0b4a34afdea4073d28d73e62bb8d6b57d700a @hadley hadley committed Jun 8, 2012
Showing with 5 additions and 3 deletions.
  1. +2 −0 NEWS
  2. +3 −3 R/geom-map.r
View
2 NEWS
@@ -27,6 +27,8 @@ DOCUMENTATION
BUG FIXES
+* `geom_map` now correctly uses set aesthetics (e.g. `colour = "green"`)
+
* Setting breaks outside the limits of the x or y axis no longer causes
errors. (Kohske Takahashi. Fixes #552)
View
@@ -54,7 +54,6 @@ NULL
#' last_plot() + coord_map()
#' ggplot(crimesm, aes(map_id = state)) + geom_map(aes(fill = value), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat) + facet_wrap( ~ variable)
#' }
-#'
geom_map <- function(mapping = NULL, data = NULL, map, stat = "identity", ...) {
# Get map input into correct form
@@ -64,7 +63,8 @@ geom_map <- function(mapping = NULL, data = NULL, map, stat = "identity", ...) {
if (!is.null(map$region)) map$id <- map$region
stopifnot(all(c("x", "y", "id") %in% names(map)))
- GeomMap$new(geom_params = list(map = map), mapping = mapping, data = data, stat = stat, ...)
+ GeomMap$new(geom_params = list(map = map, ...), mapping = mapping,
+ data = data, stat = stat, ...)
}
GeomMap <- proto(GeomPolygon, {
@@ -85,7 +85,7 @@ GeomMap <- proto(GeomPolygon, {
# Align data with map
data_rows <- match(coords$id[!duplicated(grob_id)], data$map_id)
data <- data[data_rows, , drop = FALSE]
-
+
polygonGrob(coords$x, coords$y, default.units = "native", id = grob_id,
gp = gpar(
col = data$colour, fill = alpha(data$fill, data$alpha),

0 comments on commit 75e0b4a

Please sign in to comment.