Undo layout in R

淺唱寂寞╮ 提交于 2019-12-12 16:03:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!