geom_col(aes(fill=g), position = position_dodge(width = 1)) 注:position_dodge的width参数默认值就是大柱的宽度 4. width在其他几何图形中的效果相同 再补充一下,对于其他有宽度的几何图形(例如errorbar),width参数的作用方式是一样的 对于errorbar,width参数的作用方式是一样的...
> ggplot(gg)+geom_point(aes(x=aa, y=bb, color=cc), size=3)+ + geom_errorbar(aes(x=aa, y=bb, ymin=bb-3, ymax=bb+3, color=cc), width=0.3)+theme_bw() #示例二
top_bar <- function(x){ return(mean(x)+sd(x)) } bottom_bar <- function(x){ return(mean(x)-sd(x)) } ggplot(data,aes(x_value,value, pch=variable,color=variable))+ stat_summary(geom = 'point',size=3)+ stat_summary(geom = 'errorbar',width=.05,cex=0.5, fun.min = bottom_b...
image.png 分组箱线图 代码语言:javascript 复制 ggplot(data=dfa,aes(x=Species,y=value,fill=variable))+stat_boxplot(geom="errorbar",width=0.3,position=position_dodge(0.5))+geom_boxplot(width=0.5,position=position_dodge(0.5))+scale_fill_material_d()+theme_bw()+guides(fill=guide_legend(revers...
width=.2, # Width of the error bars position=position_dodge(.9)) # Use 95% confidence intervals instead of SEM ggplot(tgc2, aes(x=dose, y=len, fill=supp)) + geom_bar(position=position_dodge(), stat="identity") + geom_errorbar(aes(ymin=len-ci, ymax=len+ci), width=.2, #...
position = position_dodge(width = 0.9), vjust = -0.5) 类似的,贴一个自己的数据写的命令,有一些参数可供参考。 ggplot(x, aes(x = Trait, y = Index, fill = Zone)) + geom_bar(stat = "identity", position = "dodge") + geom_errorbar(aes(ymin = Index, ymax =Index + SD), width ...
geom_bar(mapping=aes(x=cut,fill=cut))+ theme_classic() 1. 2. 3. 其对应关系为 如果想画箱线图: ggplot(data = mpg,mapping=aes(x=class,y=hwy)) + stat_boxplot(geom = "errorbar",width=0.15)+ geom_boxplot(width=0.3)+ theme_classic() ...
Error bar f <-ggplot(df2, aes(x = dose,y = len))f + geom_errorbar(aes(color = dose,ymin = len-sd,ymax = len+sd),width = 0.2)# 加上连线f + geom_line(aes(group = 1)) +geom_errorbar(aes(color = dose,ymin = len-sd,ymax = len+sd),width = 0.2)# 加上柱子f + ...
stat_summary(geom = "errorbar", fun.min = ebbottom, fun.max = ebtop, position = position_dodge(0.9), width=0.2)+ scale_y_continuous(expand = expansion(mult = c(0,0.1)))+ theme_bw()+ theme(panel.grid = element_blank())+