diff --git a/R/fortify-map.R b/R/fortify-map.R index 31bf3a3911..e63485fedf 100644 --- a/R/fortify-map.R +++ b/R/fortify-map.R @@ -133,6 +133,6 @@ map_data <- function(map, region = ".", exact = FALSE, ...) { borders <- function(database = "world", regions = ".", fill = NA, colour = "grey50", xlim = NULL, ylim = NULL, ...) { df <- map_data(database, regions, xlim = xlim, ylim = ylim) - geom_polygon(aes(long, lat, group = group), data = df, + geom_polygon(aes(.data$long, .data$lat, group = .data$group), data = df, fill = fill, colour = colour, ..., inherit.aes = FALSE) } diff --git a/R/plot.R b/R/plot.R index 9baaf63bea..c992530a0b 100644 --- a/R/plot.R +++ b/R/plot.R @@ -178,18 +178,17 @@ plot_clone <- function(plot) { #' @export #' @method print ggplot #' @examples -#' colours <- list(~class, ~drv, ~fl) +#' colours <- c("class", "drv", "fl") #' #' # Doesn't seem to do anything! #' for (colour in colours) { -#' ggplot(mpg, aes(displ, hwy, colour = colour)) + +#' ggplot(mpg, aes(displ, hwy, colour = .data[[colour]])) + #' geom_point() #' } #' -#' # Works when we explicitly print the plots #' for (colour in colours) { -#' print(ggplot(mpg, aes(displ, hwy, colour = colour)) + -#' geom_point()) +#' print(ggplot(mpg, aes(displ, hwy, colour = .data[[colour]])) + +#' geom_point()) #' } print.ggplot <- function(x, newpage = is.null(vp), vp = NULL, ...) { set_last_plot(x) diff --git a/man/print.ggplot.Rd b/man/print.ggplot.Rd index 4fdb4763eb..1d558a3e9e 100644 --- a/man/print.ggplot.Rd +++ b/man/print.ggplot.Rd @@ -28,18 +28,17 @@ to call \code{print()} explicitly if you want to draw a plot inside a function or for loop. } \examples{ -colours <- list(~class, ~drv, ~fl) +colours <- c("class", "drv", "fl") # Doesn't seem to do anything! for (colour in colours) { - ggplot(mpg, aes(displ, hwy, colour = colour)) + + ggplot(mpg, aes(displ, hwy, colour = .data[[colour]])) + geom_point() } -# Works when we explicitly print the plots for (colour in colours) { - print(ggplot(mpg, aes(displ, hwy, colour = colour)) + - geom_point()) + print(ggplot(mpg, aes(displ, hwy, colour = .data[[colour]])) + + geom_point()) } } \keyword{hplot}