1 有误差棒的线图 # Default line plot p<- ggplot(df2, aes(x=dose, y=len, group=supp, color=supp)) + geom_line() + geom_point()+ geom_errorbar(aes(ymin=len-sd, ymax=len+sd), width=.2, position=position_dodge(0.05)) print(p) # Finished line plot p+labs(title="Tooth length...
ggplot图的元素可以主要可以概括如下:最大的是plot(指整张图,包括background和title),其次是axis(包括stick,text,title和stick)、legend(包括backgroud、text、title)、facet这是第二层次,其中facet可以分为外部strip部分(包括backgroud和text)和内部panel部分(包括backgroud、boder和网格线grid,其中粗的叫grid.major,细...
p <- p + geom_bar(stat = "identity", color="black", width = 0.55, position = dodge) + # 条形图绘制 geom_errorbar(aes(ymin = mean, ymax = mean + sd), width = .2, position = position_dodge(0.6)) + # 误差线绘制 scale_y_continuous(limits = c(0, 16), breaks = c(0, 2...
1 有误差棒的线图 # Default line plot p<- ggplot(df2, aes(x=dose, y=len, group=supp, color=supp)) + geom_line() + geom_point()+ geom_errorbar(aes(ymin=len-sd, ymax=len+sd), width=.2, position=position_dodge(0.05)) print(p) # Finished line plot p+labs(title="Tooth length...
# Thefunctiongeom_errorbar()can be used to produce the error bars:library(ggplot2)# Fefault bar plot p1<-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=0.2,position=positio...
函数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(...
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.
ggbarplot(df, x = "dose", y = "len", add = c("mean_sd", "jitter"), error.plot = "upper_errorbar",color = "supp", palette = "jco", position = position_dodge(1.0)) 2.3标准误——基础形式 ggbarplot(df, x = "dose", y = "len", add = c("mean_se", "jitter"),color ...
geom_errorbar() + 填写主题和坐标轴标签等自定义设置 theme() # 参考常用theme df_line 同样,对于带误差线的条图(bar plot),我们关注不同民族性别之间的患病率差异,代码如下:df_bar ggplot(aes(x = factor(nation_gender), y = prevalence, ymin = prevalence - ci, ymax = prevalence ...
想要使ggplot2所绘制的箱线图带有最大最小值线,可用stat_boxplot命令,完整如下: stat_boxplot(geom=“errorbar”,width=0.15,aes(color=用于分类的列)) 其中aes是为最大最小值先添加颜色的,可以去掉,去掉即为黑色。 要注意的是,因为ggplot2的规则是图层叠加,所以如果是先作箱线图,即先输入geom_boxplot(),...