Search code examples
rplotellipsedrawellipse

Superimpose ellipse on a simple X-Y plot in R


I have some data which I have plotted using plot(x,y,..) function. Now I want to superimpose three ellipse on this plot. I know the radius for every axis and I know the center for every ellipse.How can I create such ellipse in R. Not much help is available on Internet about this. I want the plot to look like this


Solution

  • I dont know what is your dataset is... So I have created random one... I used plotrix package for this...

    library(plotrix)
    df = data.frame(x=sample(1:25),y=sample(1:25,replace=T,25))
    plot(df,col='blue')
    draw.ellipse(x= c(15), y= c(15), c(4), c(3), border = 'black', lwd = 2)
    draw.ellipse(x= c(15), y= c(15), c(5), c(4), border = 'green', lwd = 2)
    draw.ellipse(x= c(15), y= c(15), c(6), c(5), border = 'red', lwd = 2)
    

    I hope this will help you...