[R] Using auto.key with two variable plots

Chuck Cleland ccleland at optonline.net
Sat Jan 30 22:11:11 CET 2010


On 1/30/2010 3:45 PM, Jonathan Greenberg wrote:
> Rhelpers:
> 
>    Having a problem solving this.  I have an xyplot call that looks like
> this:
> 
>       
> print(xyplot(temp_species_EAM_Pred_Pop$x+temp_species_NULL_Pred_Pop$x~temp_species_EAM_Pred_Pop$Action,main=current_species,
> 
>                        xlab="Action",ylab="Predicted Pop",
>                        xlim=c(xmin,xmax),ylim=c(ymin,ymax),
>                        auto.key=list(corner=c(1,1))))
> 
> This is just a scatterplot with two response variables sharing the same
> predictor variable (temp_species_EAM_Pred_Pop$Action).  Right now, the
> key has the words "temp_species_EAM_Pred_Pop$x" and
> "temp_species_NULL_Pred_Pop$x" next to their symbols.  I would like to
> rename these in the key, say "EAM" and "NULL" -- using the group=
> command doesn't work (since these aren't really different groups).  What
> is the right way to rename these variables in the key?  Is using
> auto.key the right approach?

  Did you try setting the text parameter of the auto.key list?
Something like this:

print(xyplot(temp_species_EAM_Pred_Pop$x + temp_species_NULL_Pred_Pop$x
~ temp_species_EAM_Pred_Pop$Action,
                       main=current_species,
                       xlab="Action",ylab="Predicted Pop",
                       xlim=c(xmin,xmax),ylim=c(ymin,ymax),
                       auto.key=list(text=c('EAM','NULL'), corner=c(1,1))))

> Thanks!
> 
> --j

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list