在ggplot2可视化中创建填充的中心点作为集群的中心

时间:2018-04-17 08:48:44

标签: r ggplot2

我有以下数据集:

point_duration1 = rnorm(n=100, mean=8, sd=1.5)
point_duration2 = rnorm(n=100, mean=9, sd=1.5)
point_duration3 = rnorm(n=100, mean=7, sd=2)
point_duration_test <- c(point_duration1, point_duration2, point_duration3)

point_silence1 = rnorm(n=100, mean=0.3, sd=0.1)
point_silence2 = rnorm(n=100, mean=0.25, sd=0.15)
point_silence3 = rnorm(n=100, mean=0.15, sd=0.1)
point_silence_test <- c(point_silence1, point_silence2, point_silence3)

df_test <- data.frame(point_duration = point_duration_test, point_silence = point_silence_test)
df_test$point_silence <- ifelse((df_test$point_silence < 0),0,df_test$point_silence)
df_test$group <- 1
df_test[1:100,]$group <- 2

我用它来创建以下可视化:

ggplot(df_test, aes(x = point_duration, y = point_silence, colour = group)) +
  geom_point() +
  geom_point(data=df_test %>% 
               group_by(group) %>% 
               summarise(point_duration = mean(point_duration), point_silence = mean(point_silence)),
             size=10, shape=1)

这是有效的,但是我想创建一个坚实且充满中心的点而不是我现在得到的空心点。我找不到填补中心点的方法......有关如何做到这一点的任何建议吗?

0 个答案:

没有答案