问题
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
回答1:
Yes, use:
par(mfrow=c(1,1))
Other good answers can be found here
回答2:
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])
来源:https://stackoverflow.com/questions/29079546/undo-layout-in-r