Skip to content

Commit

Permalink
use on.exit in plot
Browse files Browse the repository at this point in the history
  • Loading branch information
max-pilz committed Mar 4, 2024
1 parent efb52d4 commit e8343f4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions R/TwoStageDesign.R
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,17 @@ setMethod("show", signature(object = "TwoStageDesign"), function(object) {
setMethod("plot", signature(x = "TwoStageDesign"),
function(x, y = NULL, ..., rounded = TRUE, k = 100) {
args <- list(...)
if(length(args) > 0) {
scores <- args[which(sapply(args, function(s) is (s, "Score")))]
if (!all(sapply(scores, function(s) is(s, "ConditionalScore"))))
stop("additional scores must be ConditionalScores")
plot_opts <- args[which(sapply(args, function(s) !is(s, "Score")))]
} else {
scores <- NULL
plot_opts <- NULL
}
if(length(args) > 0) {
scores <- args[which(sapply(args, function(s) is (s, "Score")))]
if (!all(sapply(scores, function(s) is(s, "ConditionalScore"))))
stop("additional scores must be ConditionalScores")
plot_opts <- args[which(sapply(args, function(s) !is(s, "Score")))]
} else {
scores <- NULL
plot_opts <- NULL
}
oldpar <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(oldpar))
opts <- graphics::par(c(list(mfrow = c(1, length(scores) + 2)), plot_opts))
x1 <- seq(x@c1f, x@c1e, length.out = k)
x2 <- seq(x@c1f - (x@c1e - x@c1f)/5, x@c1f - .01*(x@c1e - x@c1f)/5, length.out = k)
Expand Down

0 comments on commit e8343f4

Please sign in to comment.