How to calculate the area of ellipse drawn by ggplot2?
问题 In ggplot2, after I drawing the ellipse plot using stat_ellipse, is there any way to calculate the area of this ellipse? Here is the code and the plot: library(ggplot2) set.seed(1234) x <- rnorm (1:1000) y <- rnorm (1:1000) data <- cbind(x, y) data <- as.data.frame(data) ggplot (data, aes (x = x, y = y))+ geom_point()+ stat_ellipse() 回答1: You can calculate the area of the ellipse by finding its semi-major and semi-minor axes (as shown in this SO answer): # Plot object p = ggplot (data, aes (x