hi, i am using this script on our webserver to plot data / draw ellipses for a flex movie... would like to add the areas of the ellipses to another legend just like the means for the distance. the data looks like: x (dispersion), y (distance), Club (name of the club for grouping) thanks, sam ## usage: Rscript nikeScatter.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 shotData <- read.table(args[1], sep = ",", header=T) ## setup the pdf file name pdf(file = args[2]) ## do the plot scatterplot(y ~ x | Club, data=shotData, 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, legend.plot = FALSE) ## do the custom legends n.groups <- length(levels(shotData$Club)) col=rep(palette(), length.out=n.groups + 1) pch=1:n.groups usr <- par('usr') distance <- sapply(levels(shotData$Club),function(x) {mean(shotData[shotData$Club==x,"y"])}) dispersion <- sapply(levels(shotData$Club),function(x) {mean(shotData[shotData$Club==x,"x"])}) legend(usr[1] + 7, usr[4], legend=levels(shotData$Club), col=col[2: (n.groups+1)], pch=pch, pt.cex=.85, cex=.85) legend("topright", legend=format(distance, digits=1, nsmall=3), col=col[2:(n.groups+1)], pch=pch, pt.cex=.85, cex=.85)