How to realize column Chart in R language
This article introduces the relevant knowledge of "how to realize column chart in R language". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations. I hope you can read carefully and learn something!
Column Chart Ordinary Column Chart Cluster Column Chart Stack Column Chart df%
group_by(group)%>%
summarise(mean_value=mean(value),sd_value=sd(value)) -> df1
df1
library(ggplot2)
ggplot(data=df1,aes(x=group,y=mean_value))+
geom_col(aes(fill=group))+
geom_errorbar(aes(ymin=mean_value-sd_value,
ymax=mean_value+sd_value),
width=0.2)+
theme_bw()+
scale_y_continuous(expand=c(0,0),limits=c(0,4),
breaks = c(0,1,2,3,4))+
scale_fill_manual(values=c("#1f78b4", "#33a02c", "#e31a1c"))
image.pngdf%group_by(dose)%>%mutate(new_col=cumsum(len)) -> df1
df1
ggplot(data=df1,aes(x=dose,y=len,fill=supp))+
geom_bar(stat="identity",position="stack")+
geom_text(aes(label=len),
position = position_stack(vjust=0.5),color="white")+
geom_errorbar(aes(ymin=new_col-sd_value,ymax=new_col+sd_value),
width=0.1)+
theme_bw()+scale_fill_manual(values=c("#33a02c", "#e31a1c"))+
scale_y_continuous(expand = c(0,0),limits = c(0,70))
image.pngdf