knitr: How to show two plots of different sizes next to each other?

前端 未结 4 667
萌比男神i
萌比男神i 2020-12-09 11:28

I wanted to generate two images of different sizes, but show them side-by-side. Is this possible?

This works, but then they have to be the same size:



        
4条回答
  •  孤城傲影
    2020-12-09 12:02

    You can also use grid.arrange from gridExtra which works with grob or ggplot objects

    require(gridExtra)
    pre_fig <- rasterGrob(readPNG("paper_figures/surf_0000.png"), interpolate=TRUE)
    post_fig <- rasterGrob(readPNG("paper_figures/surf_0044.png"), interpolate=TRUE)
    grid.arrange(pre_fig, post_fig, ncol=2)
    

提交回复
热议问题