p + stat_summary(fun = mean, fun.min = function (x) {mean(x) - sd(x)}, fun.max = function (x) {mean(x) + sd(x)}, geom = "pointrange", color = "red") stat_smooth()添加光滑曲线,与geom_smooth()相同。 参数method设置平滑曲线的拟合方法,如lm线性回归、glm广义线性回归、loess多项...
ggplot(data=diamonds)+geom_histogram(mapping=aes(x=carat),binwidth=0.5) ⑩stat_summary( )函数为x的每个唯一值计算y值的摘要统计: ggplot(data=diamonds)+stat_summary(mapping=aes(x=cut,y=depth),fun.ymin=min,fun.ymax=max,fun.y=median) 11)可以使用color= 或者 fill=(这个更有用)图形属性来为...
ggplot(data=new_df,aes(x=name,y=value,fill=var4))+ stat_summary(geom = "bar",fun = "mean", position = position_dodge(0.9))+ stat_summary(geom = "errorbar", fun.min = ebbottom, fun.max = ebtop, position = position_dodge(0.9), width=0.2)+ scale_y_continuous(expand = expansion...
# dot plot with mean points p + stat_summary(fun.y=mean, geom="point", shape=18, size=3, color="red") # dot plot with median points p + stat_summary(fun.y=median, geom="point", shape=18, size=3, color="red") 1. 2. 3. 4. 5. 6. 2,向点图中增加点范围 fun.low.mean ...
stat_summary(fun.y = 'mean',geom = 'point',shape=23,size=3, fill='red') #向箱线图添加均值标记 #1.5绘制单组数据箱线图 #必须给定x参数映射任意一个值 ggplot(birthwt,aes(x=1,y=bwt))+ geom_boxplot()+ scale_x_continuous(breaks = NULL)+ #移除x轴的刻度标记 ...
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())+
aes(x = supp,y = len,fill = factor(dose))) + # 添加柱子 stat_summary(fun = mea...
stat_summary(fun.y="mean",geom="point",size=3) + stat_summary(fun.y="mean",geom=...
p1<-ggplot(mpg)+geom_point(aes(x=displ,y=hwy))p2<-ggplot(mpg)+geom_bar(aes(x=as.character(year),fill=drv),position="dodge")+labs(x="year")p3<-ggplot(mpg)+geom_density(aes(x=hwy,fill=drv),colour=NA)+facet_grid(rows=vars(drv))p4<-ggplot(mpg)+stat_summary(aes(x=drv,y=hwy...
用stat_summary() 做统计汇总并绘图。通过传递函数做统计计算,首先注意x和y 美学映射到calss 和hwy; fun = mean 是根据x 计算y,故对每个车型计算一个平均的hwy;fun.max, fun.min 同样根据x 分别计算y 的均值加减标准差;统计计算的结果将传递给几何对象参数geom 用于绘图: ...