File: test-plotly-image-trace.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 (38 lines) | stat: -rw-r--r-- 1,065 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


test_that("image trace renders", {
  plot_ly() %>%
    add_trace(
      type = "image",
      colormodel = "rgb",
      hoverinfo = "all",
      dy = 1,
      dx = 0.5,
      # TODO: do something intelligent with raster objects
      z = list(list(list(255, 0, 0), list(0, 255, 0), list(0, 0, 255)))
    ) %>%
    add_trace(
      type = "image",
      colormodel = "hsl",
      hoverinfo = "all",
      z = list(
        list(list(0, 33, 50), list(0, 66, 50), list(0, 100, 50)),
        list(list(90, 33, 50), list(90, 66, 50), list(90, 100, 50)),
        list(list(180, 33, 50), list(180, 66, 50), list(180, 100, 50)),
        list(list(270, 33, 50), list(270, 66, 50), list(270, 100, 50))
      ),
      xaxis = "x2",
      yaxis = "y2"
    ) %>%
    layout(grid = list(rows = 1, columns = 2, pattern = "independent")) %>%
    expect_doppelganger("colormodel")
})


test_that("add_image() works", {
  plot_ly() %>%
    add_image(
      z = as.raster(matrix(hcl(0, 80, seq(50, 80, 10)), nrow = 4, ncol = 5))
    ) %>%
    expect_doppelganger("raster-basic")
})