Skip to content

Improved error messages for plot addition. #3600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
improved error messages for plot addition.
  • Loading branch information
clauswilke committed Oct 31, 2019
commit 4a03ab7f4fc61c8cd73c5ae5e6d937e5daac356b
7 changes: 4 additions & 3 deletions R/plot-construction.r
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ggplot_add <- function(object, plot, object_name) {
}
#' @export
ggplot_add.default <- function(object, plot, object_name) {
stop("Don't know how to add ", object_name, " to a plot", call. = FALSE)
stop("Can't add `", object_name, "` to a ggplot object.", call. = FALSE)
}
#' @export
ggplot_add.NULL <- function(object, plot, object_name) {
Expand All @@ -102,8 +102,9 @@ ggplot_add.data.frame <- function(object, plot, object_name) {
#' @export
ggplot_add.function <- function(object, plot, object_name) {
stop(
"Don't know how to add ", object_name, " to a plot. Did you mean ",
object_name, "()?", call. = FALSE
"Can't add `", object_name, "` to a ggplot object.\n",
"Did you forget to add parentheses, as in `",
object_name, "()`?", call. = FALSE
)
}
#' @export
Expand Down