1

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.

Kalamazoo
  • 111
  • 1
  • 10
  • Can you please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Majid Sep 24 '19 at 11:34
  • @Majid: Thanks for your input. I have edited the code above to include the exact points. – Kalamazoo Sep 24 '19 at 11:40

3 Answers3

2

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

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
1

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.

fabla
  • 1,806
  • 1
  • 8
  • 20
1

I hope this helps:

dataEllipse(x1, x2, levels=c(0.95,0.95), xlim=c(1,4), ylim=c(0,0.5))
Majid
  • 1,836
  • 9
  • 19