[R] x-axis label for boxplot

David Winsemius dwinsemius at comcast.net
Thu Feb 9 02:16:25 CET 2012


On Feb 8, 2012, at 7:48 PM, John Sorkin wrote:

> I am trying to produce three boxplots and label the x axis values:
> xvalues, yvalues, zvalues.
>
> My code is below. The labels are not below the three boxplots. If  
> you could show me how to get the
> labels below the columns I would be appreciative.
> John
>
> jdata<-data.frame(x =  
> rnorm(100),y=rnorm(100,1),z=rnorm(100,-1),y=runif(100))
>
> boxplot(jdata[,"x"],jdata[,"y"],jdata[,"z"],xlab=c("x  
> values","yvalues","zvalues"))
>

You seem to be suffering under the delusion (fostered by the naming  
conventions and the state of documentation that does a poor job of  
distinguishing these issues) that "xlab" and "ylab" are going to be  
labels for individual groups or values along axes. They are not.

Instead (.. and using something more generic for xlab like "Grouping")

axis( 1, at=1:3, labels=c("x values","yvalues","zvalues") )

-- 
David.
> John David Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
> Confidentiality Statement:
> This email message, including any attachments, is for th...{{dropped: 
> 6}}
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list