拆分小提琴图(ggplot)的纯色图例?

时间:2020-08-07 23:49:53

标签: r ggplot2 legend violin-plot

我正在尝试使这张分开的小提琴剧情中的图例颜色变得牢固。我已经成功删除了此处的行(在此站点上有其他帖子之后),但是我不知道如何进行操作。

split violins

ctn_sv <- ggplot(z, aes(x = time, y = ctn_mean, fill = group), position = position_dodge(.9), alpha = .01) + 
  geom_split_violin(trim = TRUE, alpha = 0.65) +
  ggtitle("CTN: FFF vs ZZZ")+
  theme_bw() + theme(legend.title = element_blank()) +
  scale_fill_brewer(palette = "Dark2") +
  stat_summary(fun = mean, fun.min = mean, fun.max = mean,
               geom = "crossbar", 
               width = 0.25,
               position = position_dodge(width = .25)) +
  guides(fill = guide_legend(override.aes = list(linetype = 0)),
         color = guide_legend(override.aes = list(linetype = 0)))

我从这里Split violin plot with ggplot2

使用了用于分割小提琴的代码。

提前感谢您的任何建议!

1 个答案:

答案 0 :(得分:1)

您的geom =“ crossbar”给您带来了问题。您可以在stat_summary中使用show.legend = FALSE来解决此问题。参见下面的代码和相应的输出:

16807 ** (1/5) == 7.000000000000001

output

相关问题