Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility ggplot2 3.6.0 #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions tests/testthat/test-plot.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
context("plot.R unit tests")
library("data.table")

get_labs <- function(x) x$labels
if ("get_labs" %in% getNamespaceExports("ggplot2")) {
get_labs <- ggplot2::get_labs
}

# Test autoplot method for survival --------------------------------------------
# Create mock survival object
hesim_dat <- hesim_data(
Expand Down Expand Up @@ -49,11 +54,11 @@ test_that("autoplot.survival() correctly passes labels", {
test_that("autoplot.survival() allows confidence intervals", {
# Confidence intervals as lines
p <- autoplot(surv, labels = labs, ci = TRUE)
expect_equal(p$labels$fill, "curve")

expect_equal(get_labs(p)$fill, "curve")
# Confidence intervals as ribbon
p <- autoplot(surv, labels = labs, ci = TRUE, ci_style = "ribbon")
expect_equal(p$labels$fill, "curve")
expect_equal(get_labs(p)$fill, "curve")
})

test_that("autoplot.survival() works with patient weights", {
Expand Down Expand Up @@ -92,11 +97,11 @@ test_that("autoplot.stateprobs() correctly passes labels", {
test_that("autoplot.stateprobs() allows confidence intervals", {
# Confidence intervals as lines
p <- autoplot(stprobs, labels = labs, ci = TRUE)
expect_equal(p$labels$fill, "strategy_id")

expect_equal(get_labs(p)$fill, "strategy_id")
# Confidence intervals as ribbon
p <- autoplot(stprobs, labels = labs, ci = TRUE, ci_style = "ribbon")
expect_equal(p$labels$fill, "strategy_id")
expect_equal(get_labs(p)$fill, "strategy_id")

})

Expand Down