如何根据组将单个值(形状)添加到 geom_split_violin()?

How to add single values (shapes) to geom_split_violin() based on groups?

我想为我的每把半提琴添加单一参考值。

它应该看起来像这样,形状如下:

这是我当前情节的代码(第一个 img):

ggplot(data = csi, aes(x=species,y=CSI, fill=time))+
  geom_split_violin(stat = "ydensity", trim = T,scale = "width")+
  scale_fill_manual(values=c("grey40","grey60"))+
  theme(axis.text.x=element_text(angle=35,hjust = 1))

这就是我的数据集的样子:

str(csi)
'data.frame':   265196 obs. of  3 variables:
 $ species: Factor w/ 17 levels "Tilia europaea",..: 8 8 8 8 8 8 8 8 8 8 ...
 $ time   : Factor w/ 2 levels "present","future": 1 1 1 1 1 1 1 1 1 1 ...
 $ CSI    : num  0.395 0.66 0.615 0.612 0.808 ...

head(csi)
           species    time       CSI
1 Acer platanoides present 0.3953996
2 Acer platanoides present 0.6603609
3 Acer platanoides present 0.6148618
...

我有一个额外的数据框,其中包含我想添加到我的绘图中的每个物种和时间的值:

                 species    time      mean
1       Acer platanoides present 0.7069132
2       Acer platanoides  future 0.4984167
3            Acer rubrum present 0.2257700
4            Acer rubrum  future 0.1622086
...

我怎样才能做到这一点? 提前致谢并致以最诚挚的问候

我找到了想要的答案 。 对于 geom_point() 只需要添加 position=position_dodge(width=0.7) 或其他数字。感谢上面link的人!

这是我的情节:

最后的代码:(我合并了第一个 post 中提到的两个 df,将另一个 col "mean" 添加到第一个 df)

  geom_split_violin(aes(x = species,y = CSI, fill = time),
                    stat = "ydensity", trim = T, scale = "width")+
  geom_point(mapping = aes(x = species, y = mean, shape = time), position = position_dodge(width = 0.7))+
  theme(axis.text.x=element_text(angle=35,hjust = 1))