1
votes

enter image description here

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.

3
Can you please provide a reproducible example?Majid
@Majid: Thanks for your input. I have edited the code above to include the exact points.Kalamazoo

3 Answers

2
votes

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)

enter image description here

1
votes

I hope this helps:

dataEllipse(x1, x2, levels=c(0.95,0.95), xlim=c(1,4), ylim=c(0,0.5))
1
votes

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.