Skip to content

Commit 5321b6a

Browse files
committed
Better error message
1 parent c937a19 commit 5321b6a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/plot-build.r

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,12 @@ ggplot_gtable.ggplot_built <- function(data) {
273273

274274
tag_pos <- theme$plot.tag.position
275275
if (length(tag_pos) == 2) tag_pos <- "manual"
276-
stopifnot(tag_pos %in% c("topleft", "top", "topright", "left", "right",
277-
"bottomleft", "bottom", "bottomright", "manual"))
276+
valid_pos <- c("topleft", "top", "topright", "left", "right", "bottomleft",
277+
"bottom", "bottomright")
278+
if (!(tag_pos == "manual" || tag_pos %in% valid_pos)) {
279+
stop("plot.tag.position should be a coordinate or one of ",
280+
paste(valid_pos, collapse = ', '), call. = FALSE)
281+
}
278282

279283
if (tag_pos == "manual") {
280284
xpos <- theme$plot.tag.position[1]

0 commit comments

Comments
 (0)