0

I know how to put a number of plots side by side within a html output using Rmarkdown

{r maps, fig.cap = "Fig. Z - Maps", fig.show="hold", out.width="25%", fig.align = "center", echo = FALSE}

knitr::include_graphics("plots/X1.map.png")
knitr::include_graphics("plots/X2.map.png")
knitr::include_graphics("plots/X3.map.png")
knitr::include_graphics("plots/X4.map.png")

Each of these maps have been created and saved using tmap function, saving each map with the same height and width:

tmap_save(X1.map, "plots/X1.map.png", height = 4, width = 1.5)

However, when knitting the html document together the maps, although having the same widths have different heights.

Any help would be much appreciated.

Drew
  • 131
  • 8
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Sep 02 '21 at 19:21
  • 1
    Additionally are all the figures the same aspect ratio? – Phil Sep 02 '21 at 19:38

1 Answers1

-1

Have you tried setting the size of your plots in your global chunk options? This is probably not going to work if you don't have the code to those plots instead of the saved png's.

knitr::opts_chunk$set(fig.width=x, fig.height=y)

Alternatively if you only have access to the png's you can try this:

knitr::include_graphics("plots/X1.map.png"){ width=z% }
knitr::include_graphics("plots/X2.map.png"){ width=z% }
knitr::include_graphics("plots/X3.map.png"){ width=z% }
knitr::include_graphics("plots/X4.map.png"){ width=z% }

Replace the x, y, and z with the values you'd like.