Skip to content

Instantly share code, notes, and snippets.

@yihui
Created August 27, 2013 20:48
Show Gist options
  • Save yihui/6358975 to your computer and use it in GitHub Desktop.
Save yihui/6358975 to your computer and use it in GitHub Desktop.
test par('page') which will be available in R 3.0.2
stopifnot(getRversion() > '3.0.1')
par("page")
dev.off()
dev.new()
par("page")
plot(1)
par("page")
plot(2)
par("page")
par(mfrow=c(1, 2))
par("page")
plot(1)
par("page")
plot(2)
par("page")
plot(3)
par("page")
layout(matrix(c(1, 2, 1, 3, 4, 4), 3, 2, byrow=TRUE))
par("page")
plot(1)
par("page")
plot(2)
par("page")
plot(3)
par("page")
plot(4)
par("page")
plot(5)
par("page")
layout(matrix(c(1, 2, 1, 3, 4, 4), 3, 2, byrow=TRUE))
par("page")
plot(1)
par("page")
plot(2)
par("page")
dev.off()
dev.new()
setHook("before.plot.new", function() print(par("page")))
pairs(iris)
par("page")
coplot(lat ~ long | depth, data = quakes)
coplot(lat ~ long | depth * mag, data = quakes)
for(i in 1:2) fourfoldplot(UCBAdmissions)
par("page")
filled.contour(volcano)
par("page")
setHook("before.plot.new", NULL, "replace")
R Under development (unstable) (2013-08-27 r63725) -- "Unsuffered Consequences"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> stopifnot(getRversion() > '3.0.1')
>
> par("page")
[1] TRUE
> dev.off()
null device
1
>
> dev.new()
dev.new(): using pdf(file="Rplots6.pdf")
>
> par("page")
[1] TRUE
> plot(1)
> par("page")
[1] TRUE
> plot(2)
> par("page")
[1] TRUE
>
> par(mfrow=c(1, 2))
> par("page")
[1] TRUE
> plot(1)
> par("page")
[1] FALSE
> plot(2)
> par("page")
[1] TRUE
>
> plot(3)
> par("page")
[1] FALSE
>
> layout(matrix(c(1, 2, 1, 3, 4, 4), 3, 2, byrow=TRUE))
> par("page")
[1] TRUE
> plot(1)
> par("page")
[1] FALSE
> plot(2)
> par("page")
[1] FALSE
> plot(3)
> par("page")
[1] FALSE
> plot(4)
> par("page")
[1] TRUE
> plot(5)
> par("page")
[1] FALSE
>
> layout(matrix(c(1, 2, 1, 3, 4, 4), 3, 2, byrow=TRUE))
> par("page")
[1] TRUE
> plot(1)
> par("page")
[1] FALSE
> plot(2)
> par("page")
[1] FALSE
> dev.off()
null device
1
>
> dev.new()
dev.new(): using pdf(file="Rplots7.pdf")
> setHook("before.plot.new", function() print(par("page")))
>
> pairs(iris)
[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
> par("page")
[1] TRUE
> coplot(lat ~ long | depth, data = quakes)
[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
> coplot(lat ~ long | depth * mag, data = quakes)
[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
> for(i in 1:2) fourfoldplot(UCBAdmissions)
[1] TRUE
[1] TRUE
> par("page")
[1] TRUE
> filled.contour(volcano)
[1] TRUE
[1] FALSE
> par("page")
[1] TRUE
>
> setHook("before.plot.new", NULL, "replace")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment