三、带误差线的条图(Bar plot) 我们的示例数据如下: 某地2018-2020年疾病的患病率及其95%CI,数据集名称为df,计划展示不同民族性别之间的差异 代码如下,大概与线图相似,不同之处在geom_bar(): ggplot(df, aes(x = Group, y = Rate, fill = Ethnic)) + geom_bar(stat = 'identity', color = 'black...
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_boxplot():用于绘制箱线图,展示数据的中位数、四分位数和异常值。 geom_violin():用于绘制小提琴图,结合了箱线图和密度图的特点,展示数据的分布和密度。 geom_area():用于绘制面积图,展示随时间或其他连续变量的累积值。 geom_bar():用于绘制条形图,通常用于展示分类数据的频率或计数。
(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_errorbar() + 填写主题和坐标轴标签等自定义设置 theme() # 参考常用theme df_line 同样,对于带误差线的条图(bar plot),我们关注不同民族性别之间的患病率差异,代码如下:df_bar ggplot(aes(x = factor(nation_gender), y = prevalence, ymin = prevalence - ci, ymax = prevalence ...
geom_bar(): 条形图 箱线图 e+geom_boxplot() 1. 添加有缺口的箱线图 e+geom_boxplot(notch = TRUE) 1. 按dose分组映射给颜色 e+geom_boxplot(aes(color=dose)) 1. 将dose映射给填充颜色 e+geom_boxplot(aes(fill=dose)) 1. 按supp进行分类并映射给填充颜色 ggplot(ToothGrowth, aes(x=dose, ...
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.