InquilineKea
InquilineKea

Reputation: 891

How can I make multipanel plots of several png files in R?

I want to plot these png files side-by-side (from http://www.atmos.uw.edu/~akchen0/CERES_Project/ ) - arranged in a 2x1 or a 3x1 panel. I've already installed readPNG.

Upvotes: 2

Views: 3540

Answers (1)

dardisco
dardisco

Reputation: 5274

There is already a similar question on this subject, so I will repeat this with a slight modification:

Assume your plots are p1.png, p2.png...

rl <- lapply(list("p1.png", "p2.png"), png::readPNG)
gl <- lapply(rl, grid::rasterGrob)
do.call(gridExtra::grid.arrange, gl)

Giving:enter image description here

This is rather slow on my device and not terribly pretty. You may want to look at e.g. ?grid::pushViewport to gain more control over plotting and positioning. As the comments suggest, R may not be the ideal tool for this. If on Windows, something as simple as Paint may suffice and would prob. be faster.

Upvotes: 2

Related Questions