0 votes
1 view
in R Programming by (13.4k points)

Like we are creating two plots of the dataset "iris":

Boxplot:

data("iris")

library(ggplot2)

iris1 <- ggplot(iris, aes(x = Species, y = Sepal.Length)) +

  geom_boxplot() + theme_bw()

BarPlot:

iris2 <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) +

  geom_bar() + theme_bw() +

  theme(legend.position = c(0.8, 0.8))

1 Answer

0 votes
by (32.8k points)

Using R's gridExtra library we can easily plot with grid.arrange()

require(gridExtra)

gridExtra::grid.arrange(iris1,iris2)

There is a way to put it together by using cowplot library, as grid.arrange make it difficult to labels the plots with letters(A, B, C)
library(cowplot)
plot_grid(iris1, iris2, labels = "AUTO")
Hope this 
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...