File: test-scale-gradient.R

package info (click to toggle)
r-cran-ggplot2 3.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,184 kB
  • sloc: sh: 15; makefile: 5
file content (13 lines) | stat: -rw-r--r-- 445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
context("scale_gradient")

# Limits ------------------------------------------------------------------

test_that("points outside the limits are plotted as NA", {
  df <- data_frame(x = c(0, 1, 2))
  p <- ggplot(df, aes(x, 1, fill = x)) +
    geom_col() +
    scale_fill_gradient2(limits = c(-1, 1), midpoint = 2, na.value = "orange")

  correct_fill <- c("#B26D65", "#DCB4AF", "orange")
  expect_equivalent(layer_data(p)$fill, correct_fill)
})