tests/testthat/test-scale-gradient.R

# 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_equal(layer_data(p)$fill, correct_fill)
})

Try the ggplot2 package in your browser

Any scripts or data that you put into this service are public.

ggplot2 documentation built on Oct. 12, 2023, 5:08 p.m.