Draw Multiple ggplot2 Plots Side-by-Side (R Programming Example)

preview_player
Показать описание

R Code:

y = rnorm(1000))

library("ggplot2") # Load ggplot2 package

ggp1 <- ggplot(data1, aes(x = x)) + # Create first plot
geom_density()
ggp2 <- ggplot(data2, aes(x = x, y = y)) + # Create second plot
geom_point()

library("gridExtra") # Load gridExtra package

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

I am doing my Ph.D. and all your tips are so helpful for helping me to put great graphs for my journal - thank you very very much

dominiquebarrette
Автор

Thank you, very straightforward and useful as always.
I thought we could do it within the ggplot2 package, but as I learned from you we need library("gridExtra").

fernandocamargo
Автор

the 2 colums of graph grids are displayed but the graphs itself are not displaying .Any help

nanaamapinto
Автор

Hey, what about two plot for example a Boxplot and a Scatter plot on the same axis and positioning the boxplot for example at the top or side of the y -axis?

nganja
visit shbcf.ru