Dear Sam,
It's not exactly clear to me what you're doing here, since you appear to
be
specifying some of the arguments to scatterplot() (and to other functions)
in the command used to invoke R. I'm not sure why you would want to do that.
That said, you could suppress the legend that scatterplot() produces and use
the legend() command to make your own. Given what you're doing, however, it
would probably be simpler to use plot() rather than scatterplot(). You could
add the ellipses and the points with the data.ellipse() function from the
car package, and use legend() for the legend.
scatterplot() and the other plotting functions in the car package aren't
really meant for making customized graphs, but rather for easily producing
informative plots for exploring data in the context of regression analysis.
Regards,
John
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at
r-project.org]
On> Behalf Of sam stein
> Sent: June-08-09 11:49 PM
> To: r-help at r-project.org
> Subject: [R] scatterplot (car) legend modification
>
> hi,
>
> new to R and using the car package to do some scatterplots with ellipses
> hoping to add the area and center points of each ellipse to the legend?
>
> looking for some direction / ideas.... here is the script, the data is
> where
> golf shots end up by club.
>
> x (dispersion), y (distance), group (Club)
>
> thanks, sam
>
> ## usage: Rscript shotScatter.R infile outfile level1 level2 minX maxX
> minY maxY
> ## load the library
> library(car)
>
> ## get the args
> args = commandArgs(TRUE);
>
> ## get the data format is: x, y, group
> Shot_Data <- read.table(args[1],
> sep = ",",
> header=T)
>
> ## setup the pdf file name
> pdf(file = args[2])
>
> ## do the plot
> scatterplot(y ~ x | Club, data=Shot_Data,
> ellipse = TRUE,
> levels = c(as.numeric(args[3]), as.numeric(args[4])),
> robust = TRUE,
> boxplots = "",
> xlab = "Dispersion",
> ylab = "Distance",
> xlim = c(as.numeric(args[5]), as.numeric(args[6])),
> ylim = c(as.numeric(args[7]), as.numeric(args[8])),
> smooth = FALSE,
> reg.line = FALSE)
>
> ______________________________________________
> 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.