3

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

Tinniam V. Ganesh
  • 1,979
  • 6
  • 26
  • 51

2 Answers2

11

Yes, use:

par(mfrow=c(1,1))

Other good answers can be found here

Community
  • 1
  • 1
Andrew Taylor
  • 3,438
  • 1
  • 26
  • 47
1

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])