tests/testthat/test-ggplot-function.R

p <- ggplot(data = data.frame(x = 0), mapping = aes(x = x)) 

test_that("ggplotly correctly handles stat_function", {
  pl <- p + 
    stat_function(fun = function(x) x^2+3) + 
    xlim(1, 5)

    expect_doppelganger(ggplotly(pl), "stat-function")
})

test_that("ggplotly correctly handles stat_function", {
  pl <- p + 
    geom_function(fun = function(x) x^2+3) + 
    stat_function(fun = function(x) 5) + 
    xlim(1, 5)

    expect_doppelganger(ggplotly(pl), "geomfunction")
})

Try the plotly package in your browser

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

plotly documentation built on May 29, 2024, 2:23 a.m.