Skip to content

Commit 8711872

Browse files
committed
Add test for geom_line() with shape aesthetic
1 parent c1f09eb commit 8711872

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/testthat/test-ggplot-path.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,24 @@ test_that("paths with the same color but different groups stay together", {
6363

6464
save_outputs(gg, "path-colored-groups-stay-together")
6565
})
66+
67+
test_that("lines work with aesthetic shape", {
68+
df1 <- data.frame(sex = factor(c("Female", "Female", "Male", "Male")),
69+
time = factor(c("Lunch", "Dinner", "Lunch", "Dinner"),
70+
levels=c("Lunch", "Dinner")),
71+
total_bill = c(13.53, 16.81, 16.24, 17.42))
72+
gg <- ggplot(data=df1, aes(x=time, y=total_bill, group=sex, shape=sex)) +
73+
geom_line() +
74+
geom_point()
75+
info <- gg2list(gg)
76+
expect_equal(length(info), 5) # 2 lines and 2 sets of points for each group
77+
expect_identical(info[[3]]$name, "Female")
78+
expect_identical(info[[3]]$marker$symbol, "circle")
79+
expect_identical(info[[4]]$name, "Male")
80+
expect_identical(info[[4]]$marker$symbol, "triangle-up")
81+
# Layout
82+
expect_identical(info[[5]]$layout$xaxis$title, "time")
83+
expect_identical(info[[5]]$layout$xaxis$type, "category")
84+
85+
save_outputs(gg, "path-line-symbols")
86+
})

0 commit comments

Comments
 (0)