OgW - 2 months ago 15

R Question

I have some R code to plot an ellipse for a bivariate normal with known mean and variance using the

`ellipse()`

`mixtools`

`plot(ellipse(params,covariance, npoints = 500, alpha=0.01),`

xlim = c(-2,3.5),

ylim = c(0,.75), xlab="alpha", ylab = "beta")

This code works fine when just run in

`R`

Answer

`mixtools`

function `ellipse()`

offers a plot argument, look at the manual. So you can plot your ellipse like this:

```
ellipse(params, covariance,
npoints = 500, alpha=0.01,
newplot = TRUE, draw = TRUE,
xlim = c(-2,3.5), ylim = c(0,.75),
xlab="alpha", ylab = "beta")
```

The important arguments are `newplot = TRUE`

and `draw = TRUE`

. They offer you the plot of the ellipse and all other graphical parameters can be submitted to the function `ellipse()`

via the three dot argument. If `newplot = TRUE`

and `draw = TRUE`

, plot the ellipse on a new plot. If `newplot = FALSE`

and `draw = TRUE`

, add the ellipse to an existing plot.