[R] text in boxplots

Greg Snow Greg.Snow at intermountainmail.org
Fri Sep 7 17:00:57 CEST 2007


The posting guide (a link at the bottom of every e-mail from the list)
suggests including a small example of what you are trying to do.
Without an example, we have to guess at what you are trying to do.

I am still guessing since you still did not include an example.  It
appears that part of the problem may be that the scatterplot function
from the car package does not leave the user coordinate system in a
state that matches intuitively with the data.  Your call to text is
probably placing the text outside of the plotting region where it is not
visible (possibly even in someone elses cubicle/office).  The mtext
function is not affected as much by this since it uses a different
coordinate system (based on the margins rather than the user
coordinates).

To place text on the plot, you need to find the cooresponding
coordinates.  There are a few different ways to do this:

1. use par('usr') to find out what the current user coordinates are and
compute your coordinates based on that.
2. use par(usr=c(...)) to set the user coordinates to match where you
want to plot.
3. use the locator function to interactively choose the locations and
use the resulting coordinates.
4. use the cnvrt.coords function from the TeachingDemos package to
convert from figure or device coordinates to the current user coordinate
system.
5. contact the author of the function and ask him to set the user
coordinates to something more intuitive before exiting and wait for the
change.

Look at the help for par for more information, specifically look at the
'usr' entry and possibly the 'xpd' entry if you want to add text to the
marginal boxplots.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Yves Moisan
> Sent: Friday, September 07, 2007 5:05 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] text in boxplots
> 
> 
> Hi Greg,
> 
> Actually, I'm using the scatterplot function in the car 
> namespace.  My understanding is that the scatterplot is 
> turned into a boxplot when the x variable is a factor, but I 
> can't see that in the code of the function. 
> I've successfully modified the function to output regression 
> stats (R^^2,
> etc.) with the method 'text', but I can't seem to get any 
> text printed when the result of a call to scatterplot is a 
> bunch of boxplots.  
> 
> I don't know how boxplots end up being generated (I like it 
> though) in a call to car:scatterplot.  The same data in ggobi 
> would show the "standard"
> scatterplot with data aligned vertically in lines along the 
> values of the x
> (factor) variable but car:scatterplot draws nice boxes around 
> the data as a bonus.  I guess I'll need to follow with some 
> debugging tool.  I find it odd that mtext works though.  Or 
> maybe some graphics parameter is set such that text doesn't show.
> 
> Thanx Greg.
> --
> View this message in context: 
> http://www.nabble.com/text-in-boxplots-tf4394528.html#a12553104
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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