geom_mark_ellipse fail to fill the ellipse

43 Views Asked by At

I'm trying to plot with geom_mark_ellipse as a beginner. However, one ellipse keeps white.

library(ggplot2)
library(ggforce)
x1 <- runif (50, min = 10, max = 40) 
y1 <- runif (50, min = 10, max = 40)
x2 <- runif (50, min = 41, max = 71)
y2 <- runif (50, min = 10, max = 40)
x3 <- runif (50, min = 10, max = 40)
y3 <- runif (50, min = -21, max = 9)
x4 <- runif (50, min = 41, max = 71)
y4 <- runif (50, min = -21, max = 9)

df <- data.frame(x = c(x1, x2, x3, x4), y = c(y1, y2, y3, y4), 
                 cluster = c(rep('1', 50), rep('2', 50), rep('3', 50), rep('4', 50)))

ggplot(df, aes(x, y)) +
  geom_point(aes(colour = cluster)) +
  geom_mark_ellipse(alpha = 0.5, aes(group = cluster, colour = cluster, fill = cluster))

related_image

I have no idea how to solve it.

0

There are 0 best solutions below