[R] modifying legend in scatterplot matrix R

Dieter Menne dieter.menne at menne-biomed.de
Fri Feb 20 08:23:08 CET 2009

Julien Beguin <julien.beguin.1 <at> ulaval.ca> writes:

> scatterplot.matrix(~ a + b + c,
>            groups=treatment,
>            legend.plot=T,
>            )
> legend("topright",c("fenced","unefenced"), fill=NULL,bty="o",cex=3)
> --------------------------------------------------------------------
> In my dataset, the variable "treatment" contains two levels that are coded "N"
> and "Y" (for No and Yes) and appear in my "per default" legend that is located
> in the buttomright of my 3x3 scatterplot. I would like to replace N by a list
> of character: "unfenced" and Y by "fenced", as well as moving the legend in
> another place in my graphic... is someone know how to do that with a
> scatterplot?

In most cases it is easiest to assign new level to the factor;

a = as.factor(c("N","Y","Y","N"))
levels(ar)=c("unfenced","fenced") # if you want to keep orinale

legend has x,y coordinates.


More information about the R-help mailing list