Reputation: 1273
This links explains how to plot multiple graphs in a same overall plot.
Now I have three existing graphs, png1
, png2
, png3
. I want a layout like below. How to achieve this?
Thank you very much for the answer, please remember to install the packages:
install.packages("png")
library(png)
install.packages("gridExtra")
library(gridExtra)
After using the gridExtra
, I combined three graphs together. However, they had very low resolution. How can I make them at least the same resolution as the original ones?
Upvotes: 1
Views: 297
Reputation: 51894
You would use the par
or layout
function. See the examples here: https://www.rdocumentation.org/packages/graphics/versions/3.5.0/topics/layout
If you're interested in inserting image files into the plot, you'd use readPNG
and rasterImage
and/or the grid raster functions.
Example:
png1 = png::readPNG("png1.png")
png2 = png::readPNG("png2.png")
png3 = png::readPNG("png3.png")
images = list(png1, png2, png3)
grobs = lapply(images, grid::rasterGrob)
gridExtra::grid.arrange(grobs=grobs)
Upvotes: 2