[R] Setting axis scale for a boxplot

William Dunlap wdunlap at tibco.com
Mon Nov 18 20:10:00 CET 2013


> How can I set the horizontal axis limits on all three images to be the same
> for sake of comparison?

Add ylim=c(dataMin, dataMax) to each call to boxplot(), where
you specify values for dataMin and dataMax so their range is
likely to cover all your data.  ('ylim', not 'xlim' - the horizontal=TRUE
flips the meaning of 'x' and 'y'.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of David Arnold
> Sent: Monday, November 18, 2013 10:58 AM
> To: r-help at r-project.org
> Subject: [R] Setting axis scale for a boxplot
> 
> Hi,
> 
> I have this code:
> 
> par(mfrow=c(3,1))
> 
> x1=rnorm(10,60,1)
> x2=rnorm(10,65,1)
> x3=rnorm(10,70,1)
> boxplot(x1,x2,x3,horizontal=TRUE,main="Example 1")
> 
> x1=rnorm(10,60,4)
> x2=rnorm(10,65,4)
> x3=rnorm(10,70,4)
> boxplot(x1,x2,x3,horizontal=TRUE,main="Example 2")
> 
> x1=rnorm(10,60,9)
> x2=rnorm(10,65,9)
> x3=rnorm(10,70,9)
> boxplot(x1,x2,x3,horizontal=TRUE,main="Example 3")
> 
> par(mfrow=c(1,1))
> 
> How can I set the horizontal axis limits on all three images to be the same
> for sake of comparison?
> 
> D.
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Setting-axis-scale-for-a-
> boxplot-tp4680704.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list