This repository was archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that plot() does not change the user's graphical parameters
- Loading branch information
1 parent
367adb1
commit b2366f4
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
test_that("Plot", { | ||
skip_on_cran() | ||
|
||
## Capture and cleanup plot output | ||
path <- file.path(tempdir(), "Rplot.pdf") | ||
on.exit(unlink(path)) | ||
pdf(file = path) | ||
|
||
## Save graphical parameters | ||
old_par <- graphics::par(no.readonly = TRUE) | ||
|
||
## Plot... | ||
ternary_plot(NULL) | ||
|
||
## ...changes the user's graphical parameters... | ||
new_par <- graphics::par(no.readonly = TRUE) | ||
# expect_identical(new_par, old_par) # Fails | ||
|
||
dev.off() | ||
|
||
## ...but these are the dimensions of the plotting region | ||
## (so it should be OK?) | ||
keys <- new_par[!(new_par %in% old_par)] | ||
expect_named(keys, c('pin', 'plt', 'usr', 'yaxp')) | ||
}) | ||
test_that("Pairs", { | ||
skip_on_cran() | ||
|
||
## Capture and cleanup plot output | ||
path <- file.path(tempdir(), "Rplot.pdf") | ||
on.exit(unlink(path)) | ||
pdf(file = path) | ||
|
||
## Save graphical parameters | ||
old_par <- graphics::par(no.readonly = TRUE) | ||
|
||
## Plot... | ||
ternary_pairs(lava) | ||
|
||
## ...does not change the user's graphical parameters | ||
new_par <- graphics::par(no.readonly = TRUE) | ||
expect_identical(new_par, old_par) | ||
|
||
dev.off() | ||
}) |