Skip to content

Commit 6a9bc74

Browse files
committed
Make sure the length of x_aes and y_aes match
1 parent 8415be8 commit 6a9bc74

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

R/ggplot-global.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ ggplot_global$all_aesthetics <- .all_aesthetics
4646

4747
ggplot_global$base_to_ggplot <- .base_to_ggplot
4848

49+
# These two vectors must match in length and position of symmetrical aesthetics
50+
# xintercept2 is a filler to match to the intercept aesthetic in geom_abline
4951
ggplot_global$x_aes <- c("x", "xmin", "xmax", "xend", "xintercept",
50-
"xmin_final", "xmax_final", "xlower", "xmiddle", "xupper", "x0")
52+
"xmin_final", "xmax_final", "xlower", "xmiddle", "xupper", "x0", "xintercept2")
5153

52-
ggplot_global$y_aes <- c("y", "ymin", "ymax", "yend", "yintercept", "ymin_final",
53-
"ymax_final", "lower", "middle", "upper", "y0", "intercept")
54+
ggplot_global$y_aes <- c("y", "ymin", "ymax", "yend", "yintercept",
55+
"ymin_final", "ymax_final", "lower", "middle", "upper", "y0", "intercept")

tests/testthat/test-utilities.r

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,7 @@ test_that("parse_safe works with multi expressions", {
8787
expression(NA, 1, 2, a)
8888
)
8989
})
90+
91+
test_that("x and y aesthetics have the same length", {
92+
expect_equal(length(ggplot_global$x_aes), length(ggplot_global$y_aes))
93+
})

0 commit comments

Comments
 (0)