三、带误差线的条图(Bar plot) 我们的示例数据如下: 某地2018-2020年疾病的患病率及其95%CI,数据集名称为df,计划展示不同民族性别之间的差异 代码如下,大概与线图相似,不同之处在geom_bar(): ggplot(df, aes(x = Group, y = Rate, fill = Ethnic)) + geom_bar(stat = 'identity', color = 'black...
plot.margin = unit(c(1, 1, 0.5, 1),"cm")) + # 边界设置 labs(y = "Time(min)", x = "") # 标签的位置 标记统计学意义显著性 p1 <- p + geom_segment(aes(x = 0.85, y = 10, xend = 0.85, yend = 10.3)) + geom_segment(aes(x = 1.15, y = 10, xend = 1.15, yend =...
color = dose,ymin = len,ymax = len+sd),width = 0.2)多重分组的Error bar f <-ggplot(df3, aes(x = dose,y = len))# 柱状图+Errorbarf +geom_errorbar(aes(color = supp,ymin = len-sd,ymax = len+sd),position = "dodge")+ geom_bar(aes(fill = supp),stat = "identity",positio...
到这儿还有很多的非数据元素需要改动,需要用到theme函数,原图的背景版是白的,我们需要panel.background参数来设置背景版,同时我希望整幅图的title居中加粗,plot.title可以实现我的需求,同理我们需要修正坐标轴得用到axis.line,axis.title和axis.text,需要修改坐标轴上的小标可以用axis.ticks等等;上面提到的这...
2 p4<-ggplot()+ geom_errorbar(data=dat02.1, aes(x=x, ymin=mean_value-0.1, ymax=mean_value+sd_value), width=0.3, color="#e27765")+ geom_col(data=dat02.1, aes(x=x,y=mean_value), fill="#daa421")+ geom_point(data=dat02.2, aes(x=x,y=`Signal Density Detected`), color...
geom_errorbar() + 填写主题和坐标轴标签等自定义设置 theme() # 参考常用theme df_line 同样,对于带误差线的条图(bar plot),我们关注不同民族性别之间的患病率差异,代码如下:df_bar ggplot(aes(x = factor(nation_gender), y = prevalence, ymin = prevalence - ci, ymax = prevalence ...
(plot.margin=unit(c(0.1,0.1,0.1,0.1),units=,"cm"),axis.line=element_line(color="black",size=0.4),panel.grid.minor=element_blank(),panel.grid.major=element_line(size=0.2,color="#e5e5e5"),axis.text.y=element_text(color="black",size=10),axis.text.x=element_text(margin=margin(t=...
geom_boxplot() 1. 2. 3. image.png 添加误差线 这里使用到的是stat_boxplot()函数 ggplot(data = dfa, aes(x=Species,y=value,fill=Species))+ geom_boxplot()+ stat_boxplot(geom = "errorbar", width=0.3) 1. 2.
函数geom_errorbar()可以用来生成误差棒: library(ggplot2) # Default bar plot p<- ggplot(df2, aes(x=dose, y=len, fill=supp)) + geom_bar(stat="identity", color="black", position=position_dodge()) + geom_errorbar(aes(ymin=len-sd, ymax=len+sd), width=.2, position=position_dodge(...