Back to Browse

Add Marginal Plot to ggplot2 Scatterplot Using ggExtra Package in R (Example) | ggMarginal Function

883 views
Dec 19, 2021
4:51

How to draw a graphic with marginal plot using the ggplot2 and ggExtra packages in the R programming language. More details: https://statisticsglobe.com/ggplot2-graphic-with-marginal-plot-in-r R code of this video: set.seed(6897354) # Create example data x <- rnorm(200) y <- rnorm(200) + x data <- data.frame(x, y) install.packages("ggplot2") # Install & load ggplot2 package library("ggplot2") ggp <- ggplot(data, aes(x, y)) + # Create ggplot2 scatterplot geom_point() ggp # Draw ggplot2 scatterplot install.packages("ggExtra") # Install ggExtra package library("ggExtra") # Load ggExtra ggMarginal(ggp, type = "density") # Add marginal density plot ggMarginal(ggp, type = "histogram") # Add marginal histogram ggMarginal(ggp, type = "boxplot") # Add marginal boxplot ggMarginal(ggp, type = "violin") # Add marginal violin plot ggMarginal(ggp, type = "densigram") # Add marginal density & histogram Follow me on Social Media: Facebook – Statistics Globe Page: https://www.facebook.com/statisticsglobecom/ Facebook – Group for Discussions & Questions: https://www.facebook.com/groups/statisticsglobe LinkedIn – Statistics Globe Page: https://www.linkedin.com/company/statisticsglobe/ LinkedIn – Group for Discussions & Questions: https://www.linkedin.com/groups/12555223/ Twitter: https://twitter.com/JoachimSchork Music by bensound.com

Download

0 formats

No download links available.

Add Marginal Plot to ggplot2 Scatterplot Using ggExtra Package in R (Example) | ggMarginal Function | NatokHD