11context(" geom_violin" )
22
3- test_that(" " , {
3+ test_that(" range is expanded " , {
44 df <- rbind(
55 data.frame (x = " a" , y = c(0 , runif(10 ), 1 )),
66 data.frame (x = " b" , y = c(0 , runif(10 ), 2 ))
@@ -10,9 +10,10 @@ test_that("", {
1010 geom_violin() +
1111 facet_grid(x ~ . , scales = " free" ) +
1212 coord_cartesian(expand = FALSE )
13-
14- expect_equal(layer_scales(p , 1 )$ y $ dimension(), c(0 , 1 ))
15- expect_equal(layer_scales(p , 2 )$ y $ dimension(), c(0 , 2 ))
13+ expand_a <- stats :: bw.nrd0(df $ y [df $ x == " a" ]) * 3
14+ expand_b <- stats :: bw.nrd0(df $ y [df $ x == " b" ]) * 3
15+ expect_equal(layer_scales(p , 1 )$ y $ dimension(), c(0 - expand_a , 1 + expand_a ))
16+ expect_equal(layer_scales(p , 2 )$ y $ dimension(), c(0 - expand_b , 2 + expand_b ))
1617})
1718
1819# create_quantile_segment_frame -------------------------------------------------
@@ -31,13 +32,5 @@ test_that("quantiles do not fail on zero-range data", {
3132
3233 # This should return without error and have length one
3334 expect_equal(length(layer_grob(p )), 1 )
34-
35- # All rows should be identical in layer_data, with some specific values
36- unique.layer.data <- unique(layer_data(p ))
37- expect_equal(nrow(unique.layer.data ), 1 )
38- expect_equal(unique.layer.data $ density , 0.55216039 )
39- expect_equal(unique.layer.data $ count , 1.65648117 )
40- expect_equal(unique.layer.data $ xmin , 0.55 )
41- expect_equal(unique.layer.data $ xmax , 1.45 )
4235})
4336
0 commit comments