#rprogramming #datavisualization #ggplot2 #distribution #boxplot #histogram #densityplot #violinplot #dotplot #stripchart #ridgeline #raincloudplot #halfeyeplot #beeswarmplot
In this video, I have demonstrated how to plot data distributions using very simple ggplot2 code. histogram, density plot, boxplot, strip chart, dot plot, ridgeline plot, halfeyeplot, eyeplot, raincloud plot has been explained.
The code is provided below.
Facebook page:
/ rajendrachoureisc
Mail Id:
[email protected]
youtube playlist:
• R programming tutorials
code
library(ggplot2)
library(ggdist)
library(ggbeeswarm)
head(iris)
str(iris)
ggplot(iris,aes(Sepal.Length,fill=Species,color=Species))+
geom_histogram(alpha=0.5)
ggplot(iris,aes(Sepal.Length,fill=Species,color=Species))+
geom_density(alpha=0.5)
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
geom_boxplot(alpha=0.5)
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
geom_violin(alpha=0.5)
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
geom_dotplot(binaxis="y",dotsize=0.5,stackdir = "center")
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
geom_beeswarm()
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
stat_dots()
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
geom_jitter(position=position_jitter(0.1))
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
stat_eye(alpha=0.3)
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
stat_halfeye(alpha=0.3)
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
stat_halfeye(alpha=0.3,justification=-0.2)+
geom_boxplot(width=0.12,alpha=0.3)+
stat_dots(side="left",justification=+1.1)+
coord_flip()+
theme_bw()+
theme(legend.position = "none")
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
stat_halfeye(alpha=0.3,justification=-0.2)+
geom_boxplot(width=0.12,alpha=0.3)+
geom_beeswarm()+
coord_flip()+
theme_bw()+
theme(legend.position = "none")
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
stat_halfeye(alpha=0.5,justification=-0.2, adjust=0.3)+
geom_boxplot(width=0.12,alpha=0.3)+
geom_jitter(position=position_jitter(width=0.12))+
coord_flip()+
theme_bw()+
theme(legend.position = "none")
ggplot(iris,aes(Species,Sepal.Length,fill=Species,color=Species))+
stat_halfeye(alpha=0.5,justification=-0.2, adjust=0.3)+
geom_boxplot(width=0.12,alpha=0.3)+
geom_rug()+
coord_flip()+
theme_bw()+
theme(legend.position = "none")