Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo layout in R

Tags:

r

layout

reset

I initially create a plot which is a combination of boxplot & histogram. For this I set

nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE),  height = c(1,3))
par(mar=c(2,2,1,1))
# Draw box plot
# Draw histogram

After this I need to create a regular plot. But I find that all subsequent plots try to follow the same layout. One on top and another one below.

How can I reset the layout to default?

Should I use nf <- layout(mat = matrix(c(1,1),1,1, byrow=FALSE))

Thanks Ganesh

like image 540
Tinniam V. Ganesh Avatar asked Nov 04 '25 21:11

Tinniam V. Ganesh


2 Answers

Yes, use:

par(mfrow=c(1,1))

Other good answers can be found here

like image 196
Andrew Taylor Avatar answered Nov 07 '25 15:11

Andrew Taylor


You should save the par's before change it, and use it during the initialization.

Exemple :

### #data set
df = iris
### #Save par's version
par_temp = par()
### #change par's
par(mfrow=c(2,1))
plot(df[,1:2])
hist(df[,1])
### #initialization of par's
par(par_temp)
hist(df[,1])
like image 42
abdelhadi danba Avatar answered Nov 07 '25 14:11

abdelhadi danba