tests/testthat/test-viridis.R

df <- data_frame(x = 1, y = 1, z = "a", tier = factor("low", ordered = TRUE))

test_that("viridis scale changes point color", {
  p1 <- ggplot(df, aes(x, y, colour = z)) +
    geom_point()
  p2 <- p1 + scale_colour_viridis_d()

  expect_false(layer_data(p1)$colour == layer_data(p2)$colour)
  expect_equal(layer_data(p2)$colour, "#440154FF")
})

test_that("viridis scale is used by default for ordered factors", {
  p <- ggplot(df, aes(x, y, colour = tier)) + geom_point()

  expect_equal(layer_data(p)$colour, "#440154FF")
})

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.