Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (19k 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 (33.1k 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 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...