Reset par to the default values at startup

前端 未结 6 1119
情书的邮戳
情书的邮戳 2020-12-02 07:52

Normally when I make my own plot functions, I make a construct :

op <- par(\"mypar\"=myvalue)
on.exit(par(op))

which is the standard way

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 07:54

    This is hacky, but:

    resetPar <- function() {
        dev.new()
        op <- par(no.readonly = TRUE)
        dev.off()
        op
    }
    

    works after a fashion, but it does flash a new device on screen temporarily...

    E.g.:

    > par(mfrow = c(2,2)) ## some random par change
    > par("mfrow")
    [1] 2 2
    > par(resetPar())     ## reset the pars to defaults
    > par("mfrow")        ## back to default
    [1] 1 1
    

提交回复
热议问题