Skip to content

A problem of splitting the right screen in 3 or more independent vertical boxes:

5 messages · Sarah Goslee, David Winsemius, Aldi Kraja

#
Hi,
Based on par function, I can split the screen into  two parts left and 
right.
I wish x occupies the half left screen, and all plants occupy half right 
screen, which happens right now.

But I wish the right screen, to be split in 3 or more vertical parts 
where each pair of the same type of plant, are together in its own block 
of boxplot, because each plant has its own unit of measure.
Let's say wheat is measured in ton, tomato in pound and cucumbers as 
counts. :-)

x<-rnorm(1000,mean=0,sd=1,main="Right screen")

wheat1<-rnorm(100,mean=0,sd=1)
wheat2<-rnorm(150,mean=0,sd=2)
tomatos3<-rnorm(200,mean=0,sd=3)
tomatos4<-rnorm(250,mean=0,sd=4)
cucumbers5<-rnorm(300,mean=0,sd=5)
cucumbers6<-rnorm(400,mean=0,sd=6)
par(mfrow=c(1,2))

hist(x, main="Left screen OK")

boxplot(wheat1,wheat2,tomatos3,tomatos4,cucumbers5,cucumbers6)
title ("Right screen: boxplot with plants")

Thank you in advance for any suggestions,

Aldi

--
#
Hmm,
I had a typo paste by mistake in my x vector
It has to be:

x<-rnorm(1000,mean=0,sd=1)
wheat1<-rnorm(100,mean=0,sd=1)
wheat2<-rnorm(150,mean=0,sd=2)
tomatos3<-rnorm(200,mean=0,sd=3)
tomatos4<-rnorm(250,mean=0,sd=4)
cucumbers5<-rnorm(300,mean=0,sd=5)
cucumbers6<-rnorm(400,mean=0,sd=6)
par(mfrow=c(1,2))

hist(x, main="Left screen OK")

boxplot(wheat1,wheat2,tomatos3,tomatos4,cucumbers5,cucumbers6)
title ("Right screen: boxplot with plants")

Thanks,

Aldi
On 5/3/2013 4:46 PM, Aldi Kraja wrote:
--
#
Hi Aldi,

You might want
?layout
instead.

Sarah
On Fri, May 3, 2013 at 5:54 PM, Aldi Kraja <aldi at wustl.edu> wrote:

  
    
#
On May 3, 2013, at 3:21 PM, Sarah Goslee wrote:

            
Indeed. In particular a matrix argument might be:

matrix(c(1,2,3, 4,4,4)
I think you will need a separate call to boxplot for each grouping. The `boxplot` function will nto be able to access the device specifications.
7 days later
#
For those that may have this question in the future, here are two solutions:
As suggested from David and Sarah,
One has to remove par function from defining screen splits, instead use 
layout function.
For example:
  layout(matrix(c(1,1,2,3),2,2,byrow=T))
which says, split the screen in 4 blocks, of them use block space 1 and 
2 oriented by row for picture 1, and the two remaining blocks for 
picture 2 and picture 3. Similarly, one can split the screen into 6, 8 
blocks and so on by changing also how many blocks of space you want to 
assign to a specific picture for example.
layout(matrix(c(1,1,1,2,3,4,5),2,3,byrow=T)) ## six splits, of those 
first 3 belong to picture 1
layout(matrix(c(1,1,2,3,4,5,6,7),2,4,byrow=T))  ## 8 splits of those 
first 2 belong to picture 1 and so on.

Dennis Murphey provided also another beautiful solution via ggplot2. See 
following.
Thank you,
Aldi
On 5/3/2013 7:57 PM, Dennis Murphy wrote:

        
On 5/3/2013 6:07 PM, David Winsemius wrote: