File: test-ggplot-violin.R

package info (click to toggle)
r-cran-plotly 4.10.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 30,636 kB
  • sloc: javascript: 195,272; sh: 24; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


gg <- ggplot(mtcars, aes(factor(cyl), mpg)) + geom_violin()

test_that("basic geom_violin works", {
  L <- expect_doppelganger_built(gg, "violin")
  expect_equivalent(length(L$data), 1)
  tr <- L$data[[1]]
  expect_identical(tr$type, "scatter")
  expect_true(tr$fill == "toself")
  expect_false(tr$showlegend)
  expect_true(all(grepl("density", tr$text[!is.na(tr$text)])))
  expect_true(tr$hoverinfo == "text")
})


gg2 <- ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(cyl))) + geom_violin()

test_that("geom_violin with fill aes works", {
  L <- expect_doppelganger_built(gg2, "violin-aes")
  expect_equivalent(length(L$data), 3)
  expect_true(L$layout$showlegend)
  expect_equivalent(sum(unlist(lapply(L$data, "[[", "showlegend"))), 3)
})