Marginal plots using ggExtra: Advanced ggplot2 Show raw data with its distribution

Опубликовано: 04 Май 2026
на канале: Rajendra Choure
2,159
65

#rprogramming #ggplot2 #ggextra #marginalplot #datadistribution #scatterplot

In this video, I have explained plotting marginal plots using ggplot2 and its extension package ggExtra
Marginal plots ar scatter plots with distribution plots on the margin
Scatter plots show relationship but assessing and comparing distribution from scatter is not easy on the eyes.
Marginal plots help the audience to see and compare distributions without any effort.

The marginal plots can be any of the distribution plot- densityplot, histogram, boxplot, violin plot or densigram. Densigram is a combination of histogram and densityplot.


code

install.packages("ggExtra")

library(ggExtra)
library(ggplot2)

str(iris)

p = ggplot(iris,aes(Sepal.Length,Sepal.Width,color=Species))+
geom_point()+
theme_bw()+
theme(legend.position = "bottom")+
geom_smooth()

ggMarginal(p,groupColour = TRUE,groupFill = TRUE,type="density")

Facebook page:
  / rajendrachoureisc  

Mail Id:
[email protected]

youtube playlist:
   • R programming tutorials