I have an R function which produces 95% confidence ellipses for scatterplots. The output looks like this, having a default of 50 points for each ellipse (50 rows):
Keelan Evanini, Ingrid Rosenfelder and Josef Fruehwald (JoFrhwld@gmail.com) have created a ggplot2 stat implementation of a 95% confidence interval ellipses (and an easier way to plot ellipses in ggplot2):
GitHub stat-ellipse.R
their site
You can use it as:
library(ggplot2)
library(devtools)
library(digest)
source_url("https://raw.github.com/low-decarie/FAAV/master/r/stat-ellipse.R")
qplot(data=df, x=x, y=y, colour=colour)+stat_ellipse()
To create the data
set.seed(101)
n <- 1000
x <- rnorm(n, mean=2)
y <- 1.5 + 0.4*x + rnorm(n)
colour <- sample(c("first", "second"), size=n, replace=T)
df <- data.frame(x=x, y=y, colour=colour)