- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the size of plots arranged using grid.arrange in R?
To change the size of plots arranged using grid.arrange, we can use heights argument. The heights argument will have a vector equal to the number of plots that we want to arrange inside grid.arrange. The size of the plots will vary depending on the values in this vector.
Consider the below data frame −
x<-rnorm(20) y<-rpois(20,2) df<-data.frame(x,y) df
x y 1 2.44725895 4 2 -1.30716203 2 3 -0.98084721 6 4 0.31704022 3 5 1.09460383 2 6 0.76611276 1 7 0.93073818 1 8 -0.84915028 2 9 1.27882442 0 10 0.77428764 1 11 0.48511829 0 12 -1.20333353 0 13 -0.66665709 0 14 -0.12132914 4 15 0.46865269 1 16 0.71771117 1 17 0.76447810 2 18 0.01445573 1 19 -0.75449056 3 20 1.18946339 3
Loading ggplot2 package and creating two plots −
library(ggplot2) p1<-ggplot(df,aes(x))+geom_histogram(bins=2) p2<-ggplot(df,aes(x,y))+geom_point()
Loading gridExtra package and arranging above plots using grid.arrange −
Arranging plots using grid.arrange with varying heights −
- How to display a list of plots with the help of grid.arrange in R?
- How to create two plots using ggplot2 arranged in a vertical manner in R?
- How to reduce the space between two plots that are joined with grid.arrange in R?
- How to create the plots arranged in a list that were generated using ggplot2 in R?
- How to change the tick size using ggplot2 in R?
- How to arrange a list of scatterplots in R using grid.arrange?
- How to change the title size of a graph using ggplot2 in R?
- How do I change the font size of the scale in Matplotlib plots?
- How to change the text size of Y-axis title using ggplot2 in R?
- How to change the size of dots in dotplot created by using ggplot2 in R?
- How to change default point size of geom_point in R?
- How to change the orientation and font size of x-axis labels using ggplot2 in R?
- How to change the font size of legend in base R plot?
- How to change the size of correlation coefficient value in correlation matrix plot using corrplot in R?
- How to change the point size in geom_point conditionally in R?