Reputation: 141
x1 <- c(2.525729, 2.674149, 2.079442, 2.197225, 2.970414, 2.079442, 2.197225, 1.945910, 1.945910, 2.197225, 1.871802, 2.351375,2.302585, 1.504077, 1.945910, 2.140066, 1.871802, 2.079442, 1.252763, 2.079442, 2.862201, 2.351375, 2.484907, 1.791759,2.564949)
x2 <- c(0.2701716, 0.2461830, 0.2397317, 0.3015113, 0.2058467, 0.2752409, 0.1765011, 0.2851330, 0.2911113, 0.2024441, 0.2344036, 0.2132007, 0.1754116, 0.2312486, 0.2515773, 0.2531848, 0.2886751, 0.2795085, 0.1957401, 0.2626129, 0.1537552, 0.2390457, 0.2141765, 0.3100868, 0.1976424)
library(car)
dataEllipse(x1,x2,levels=c(0.95,0.95))
The ellipse is very large in the plot and cannot be seen entirely. Does anyone know how to scale the ellipse so that the entire ellipse can be seen in the plot? Thank you.
Upvotes: 1
Views: 348
Reputation: 1816
One simple way to solve this issue is setting different axis ranges.
Code
dataEllipse(x1,x2,levels=c(0.95,0.95), xlim = c(0,4), ylim = c(-1,1))
How u set the axis range, is of course up to you xlim = c(0,4), ylim = c(-1,1)
is just an example.
Upvotes: 1
Reputation: 24252
This is a solution with an automatic setting of the axes range:
library(car)
set.seed(1234)
x1 <- rnorm(20)
x2 <- rnorm(20)
# Get ellipse coordinates without drawing
out <- dataEllipse(x1,x2,levels=c(0.95,0.95), draw=F)
# Calculate min and max of x and y coordinates
rng <- do.call(rbind, lapply(out, function(mtx) apply(mtx,2,range)))
mnmx <- apply(rng, 2, range)
# Use calculated min and max for setting axes range
dataEllipse(x1,x2,levels=c(0.95,0.95), xlim=mnmx[,1], ylim=mnmx[,2], draw=T)
Upvotes: 2
Reputation: 1854
I hope this helps:
dataEllipse(x1, x2, levels=c(0.95,0.95), xlim=c(1,4), ylim=c(0,0.5))
Upvotes: 1