File: test-ggplot-quantile.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 (55 lines) | stat: -rw-r--r-- 1,111 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55




test_that("Basic geom_quantile() works", {
  
  skip_if_not_installed("quantreg")
  
  p <- ggplot(mpg, aes(displ, 1 / hwy)) + 
    geom_point() +
    geom_quantile()
  
  # partial match of 'coef' to 'coefficients' 
  l <- suppressWarnings(plotly_build(p)$x)
  
  expect_length(l$data, 4)
  
  for (i in 2:4) {
    tr <- l$data[[i]]
    expect_equivalent(tr$type, "scatter")
    expect_equivalent(tr$mode, "lines")
    expect_equivalent(
      tr$line$color, toRGB(GeomQuantile$default_aes[["colour"]])
    )
  }
  
})

test_that("Can specify gpar() in geom_quantile()", {
  
  skip_if_not_installed("quantreg")
  
  # TODO: implement lineend/linejoin/linemitre?
  
  p <- ggplot(mpg, aes(displ, 1 / hwy)) + 
    geom_point() +
    geom_quantile(colour = "red", alpha = 0.5)
  
  # partial match of 'coef' to 'coefficients' 
  l <- suppressWarnings(plotly_build(p)$x)
  
  expect_length(l$data, 4)
  
  for (i in 2:4) {
    tr <- l$data[[i]]
    expect_equivalent(tr$type, "scatter")
    expect_equivalent(tr$mode, "lines")
    expect_equivalent(
      tr$line$color, toRGB("red", 0.5)
    )
  }
  
  
})