[英]Formatting a violin plot in ggplot2
我正在努力按照我想要的方式格式化这个小提琴图。
首先,我想知道如何使绘图、均值和误差条的轮廓与每个点上显示的点的颜色相同,同时删除这些点的黑色轮廓并将它们的形状更改为用于每个均值的相同形状. 其次,我想知道如何降低 x 轴上绘图的宽度并对误差条执行相同操作,以便它们不会覆盖每把小提琴的整个宽度。
这是我目前拥有的代码:
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
#
Dta_lng %>%
ggplot(aes(x= Group, y= `Glucose m+6`, shape=Group)) +
geom_violin() +
geom_errorbar(stat = "summary", fun.data = "mean_sdl",
fun.args = list(mult = 1),
position = position_dodge(width = 0.9)) +
geom_jitter(aes(fill=Group),width=0.1, alpha=0.6, pch=21, color="black") +
#Adjusting limits on Y axis to encompass all data and mimic figure 1a
ylim(0.0,0.6) +
#Adding colours manually. Original figure is not colour blind friendly so colour blind friendly palette will be used.
scale_fill_manual(values=cbPalette) +
theme_classic() +
# Inserted mean with the corresponding point shapes from original figure. Size versus the other points was increased so the mean is easily identified.
stat_summary(fun.y=mean, geom="point", shape=c(16,15), size=3)
您应该始终提供一些最少的数据供我们复制您的结果。
对于颜色,相应的参数是col = 'color'
,对于点,您应该尝试fill =
而不是col =
。 在美学中尝试使用group = Group
而不是shape = Group
以便您可以自己指定形状。
虽然不太了解你的第二个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.