Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tidyverse/ggplot2
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed May 21, 2018
2 parents 756ad7b + 2254247 commit eecc450
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
@@ -1,4 +1,5 @@
# ggplot2 2.2.1.9000
To be released as 2.3.0

## Breaking changes

Expand Down
2 changes: 1 addition & 1 deletion R/plot-build.r
Expand Up @@ -159,7 +159,7 @@ ggplot_gtable.ggplot_built <- function(data) {
plot_table <- layout$render(geom_grobs, data, theme, plot$labels)

# Legends
position <- theme$legend.position
position <- theme$legend.position %||% "right"
if (length(position) == 2) {
position <- "manual"
}
Expand Down
6 changes: 6 additions & 0 deletions R/plot-construction.r
Expand Up @@ -38,6 +38,12 @@
#' # This can be useful to return from a function.
#' base + list(subset(mpg, fl == "p"), geom_smooth())
"+.gg" <- function(e1, e2) {
if (missing(e2)) {
stop("Cannot use `+.gg()` with a single argument. ",
"Did you accidentally put + on a new line?",
call. = FALSE)
}

# Get the name of what was passed in as e2, and pass along so that it
# can be displayed in error messages
e2name <- deparse(substitute(e2))
Expand Down
8 changes: 4 additions & 4 deletions revdep/email.yml
@@ -1,4 +1,4 @@
release_date: ???
rel_release_date: ???
my_news_url: ???
release_version: ???
release_date: June 25
rel_release_date: one month
my_news_url: https://github.com/tidyverse/ggplot2/blob/master/NEWS.md#ggplot2-2219000
release_version: 2.3.0
18 changes: 18 additions & 0 deletions tests/testthat/test-error.R
@@ -0,0 +1,18 @@
context("error")

test_that("various misuses of +.gg (#2638)", {
expect_error(
{
ggplot(mtcars, aes(hwy, displ))
+ geom_point()
},
"Cannot use `+.gg()` with a single argument. Did you accidentally put + on a new line?",
fixed = TRUE
)

expect_error(
geom_point() + geom_point(),
"Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?",
fixed = TRUE
)
})

0 comments on commit eecc450

Please sign in to comment.