[R] what is the expected behavior of layout.show(n)

Yousri Fanous you@r|@|@nou@ @end|ng |rom gm@||@com
Wed Apr 29 15:09:05 CEST 2020


Hello

Load package: ACSWR
> data(sample)
> layout(matrix(c(1,1,2,2,3,3,0,4,4,5,5,0),2,6,byrow=T),respect=F)
> hist(sample[,1],main="Hist for sample I",xlab="sample 1",ylab="freq")
> hist(sample[,2],main="Hist for sample II",xlab="sample 2",ylab="freq")
> hist(sample[,3],main="Hist for sample III",xlab="sample 3",ylab="freq")
> hist(sample[,4],main="Hist for sample IV",xlab="sample 4",ylab="freq")
> hist(sample[,5],main="Hist for sample V",xlab="sample 5",ylab="freq")

This works as expected: Histograms 1-3 are displayed on the first row and
histograms 4 and 5 on the second row

However when I use layout.show to check the layout , it appears that
layout.show(3) consumes the first 3 locations

> layout(matrix(c(1,1,2,2,3,3,0,4,4,5,5,0),2,6,byrow=T),respect=F)
> layout.show(3)
> hist(sample[,1],main="Hist for sample I",xlab="sample 1",ylab="freq")
> hist(sample[,2],main="Hist for sample II",xlab="sample 2",ylab="freq")
> hist(sample[,3],main="Hist for sample III",xlab="sample 3",ylab="freq")
> hist(sample[,4],main="Hist for sample IV",xlab="sample 4",ylab="freq")
> hist(sample[,5],main="Hist for sample V",xlab="sample 5",ylab="freq")

Now the first row shows 3 empty rectangles and histogram 1 and 2 are
displayed on row 2 while histograms 3-5 are displayed on the top row in a
different graph / page

If I use layout.show(5) then each histogram is displayed on a separate
sheet as if the layout was fully consumed

Few questions here:
1) in case of layout.show(3) why the layout was still remembered / recycled
2) with layout.show(5) why was the layout totally dismissed. I expected at
least it would restart over with 3 graphs in first row and 2 graphs in
second row to be consistent in behavior with layout.show(3)
3) layout.show(x) purpose is to check if my layout is correct. It must not
leave any side effect on the main plots.
>From the help of function layout this line relates to layout.show

layout.show(n) plots (part of) the current layout, namely the outlines of
the next n figures.

It does not describe the behavior I am seeing

4) Finally is there a way to undo the effect of layout.show except re-enter
my layout again?

Yousri

Software Developer
IBM Canada

	[[alternative HTML version deleted]]



More information about the R-help mailing list