Advanced barplot: Barplot with overlayed points to visualise data distribution

preview_player
Показать описание
#datavisualization #barplot #barcharts #ggplot2 #rprogramming

In this video, I discussed plotting barplot to visualise data summary as well data distribution.

I have explained how to summarise data and plot barplot and overlay jittered data points over those bars.

I have explained all the customisations required to make the plot more explanatory.

R code for this video is pasted below

Facebook page:

Mail Id:

youtube playlist:

# code ( pipe has to be removed because youtube do not accept angled bracket. )
a=rnorm(25,5,0.3)
b=rnorm(25,6,0.3)

group=rep(letters[1:2],each=25)

values=c(a,b)

boxplot(values~group)

library(dplyr)

df_sum = group_by(df,group)
df_sum= summarise(ds_sum,meanV=mean(values),sdV=sd(values))

df_sum
library(ggplot2)
ggplot(df_sum,aes(group,meanV))+
geom_col(fill= c("gray60","white"),color="gray20",width=1)+
geom_errorbar(aes(ymin=meanV-sdV,ymax=meanV+sdV),width=0.1,size=1)+
scale_y_continuous(expand=c(0,0))+
theme_classic()+
geom_jitter(data=df,mapping=aes(group,values),position=position_jitter(width=0.2),alpha=0.5,size=2)+
expand_limits(y=c(0,max(values)+0.3))+
geom_text(label=c("c","d"),vjust=-0.3,hjust=-2.3)
Рекомендации по теме
Комментарии
Автор

You are great, thank you so much.
Nb: First comment.

mohamedlagzouli
welcome to shbcf.ru