File: test-ggplot-errorbar-horizontal.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 (23 lines) | stat: -rw-r--r-- 818 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


test_that("geom_errorbarh gives horizontal errorbars", {

  df <- data.frame(
    trt = factor(c(1, 1, 2, 2)),
    resp = c(1, 5, 3, 4),
    group = factor(c(1, 2, 1, 2)),
    se = c(0.1, 0.3, 0.3, 0.4)
  )
  g <- ggplot(df, aes(resp, trt, colour=group)) + geom_point()
  # Define the limits of the horizontal errorbars
  g <- g + geom_errorbarh(aes(xmax = resp + se, xmin = resp - se))

  L <- expect_doppelganger_built(g, "errorbar-horizontal")

  # Expect scatter plot and its error bars to have the same color
  expect_equivalent(L$data[[1]]$marker$color, L$data[[3]]$error_x$color)
  expect_equivalent(L$data[[2]]$marker$color, L$data[[4]]$error_x$color)
  # Expect given errorbar values
  expect_equivalent(L$data[[3]]$error_x$array, c(0.1, 0.3))
  expect_equivalent(L$data[[4]]$error_x$array, c(0.3, 0.4))
})