1

Here is a MWE:

library(ggpubr)

# Box plot (bp)
bxp <- ggboxplot(ToothGrowth, x = "dose", y = "len",
             color = "dose", palette = "jco")
bxp
# Dot plot (dp)
dp <- ggdotplot(ToothGrowth, x = "dose", y = "len",
             color = "dose", palette = "jco", binwidth = 1)
dp

ggarrange(bxp, dp, bxp + rremove("x.text"), 
      labels = c("A", "B", "C"),
      ncol = 2, nrow = 2)

ggarrange(bxp,
      ncol = 2, nrow =2)

I have made 2 graphs. The first one has 3 graphs in a 2 x 2 grid.

The second has 1 graph also in the 2 x 2 grid. This way the initial 3 graphs and the last 1 graph are of the same size.

How can I create the last graph in a 2 x 1 grid but it should remain the same size as it was in a 2 x 2 grid ?

user2338823
  • 501
  • 1
  • 3
  • 16
  • You can explicitly set the panel size for each individual plot https://stackoverflow.com/a/53287398/786542 – Tung Nov 30 '18 at 12:42

1 Answers1

0

When you store a graph, for example using ggsave(), it has parameters height and width that can be specified:

ggsave(filename, plot = last_plot(), device = NULL, path = NULL,
  scale = 1, width = NA, height = NA, units = c("in", "cm", "mm"),
  dpi = 300, limitsize = TRUE, ...)

By settling it to the same numbers, you would get the same size plot.

Also, if you press export on the plot window, and then save as image, you will get the image below, and in the red part you can specify the size of the image.

enter image description here

Cheers !

Carles
  • 2,731
  • 14
  • 25
  • I plan to use this in an Rmarkdown document. I can set fig.width and fig.height for that chunk. I guess that's the way forward? Is there any other way ? – user2338823 Nov 30 '18 at 12:02
  • You could do so. However, there are other possible ways in this link https://stackoverflow.com/questions/15625990/how-to-set-size-for-local-image-using-knitr-for-markdown – Carles Nov 30 '18 at 12:05