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

preview_player
Показать описание
R code of this video:

x <- rnorm(200)
y <- rnorm(200) + x

library("ggplot2")

ggp <- ggplot(data, aes(x, y)) + # Create ggplot2 scatterplot
geom_point()
ggp # Draw ggplot2 scatterplot

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:

Рекомендации по теме
Комментарии
Автор

is it possible to add marginal plots whilst also using facet_wrap?

oil_lord
Автор

i have an error in this script"Error: unexpected input in "x <""

rodrigopalmacl