-
I have previously used However, this does not work for plots made from I am currently trying this option from @raagagrawal (write plots to disk, read them in using cowplot, However, I am curious if anyone has other solutions for combining multipanelplots into 1 page and labeling them? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Yup a couple of suggestions. In But if that doesn't work, I believe the general solution is to do I believe there's an example of the first in |
Beta Was this translation helpful? Give feedback.
-
It definitely does -- there should be examples on our internal github repo to find, and that's the standard mechanism we'll want to be using. |
Beta Was this translation helpful? Give feedback.
-
@jarbet For example: library(BoutrosLab.plotting.general);
set.seed(13);
sample.data <- data.frame(x = rnorm(100), y = rnorm(100))
plot1 <- create.scatterplot(
y ~ x,
data = sample.data
);
plot2 <- create.histogram(sample.data$y);
plot1.mpp <- create.multipanelplot(list(plot1), layout.height = 1, layout.width = 1);
plot2.mpp <- create.multipanelplot(list(plot2), layout.height = 1, layout.width = 1);
class(plot1.mpp) <- c('multipanel', 'frame', 'gTree', 'grob', 'gDesc');
class(plot2.mpp) <- c('multipanel', 'frame', 'gTree', 'grob', 'gDesc');
plot1.anno.mpp <- placeGrob(plot1.mpp, textGrob('A', x = 0.1, y = 0.9, gp = gpar(fontface = 'bold', cex = 2)));
plot2.anno.mpp <- placeGrob(plot2.mpp, textGrob('B', x = 0.1, y = 0.9, gp = gpar(fontface = 'bold', cex = 2)));
combined.fig <- gridExtra::grid.arrange(plot1.anno.mpp, plot2.anno.mpp, ncol = 2);
write.plot(
combined.fig,
width = 12,
height = 6,
filename = 'test.png',
resolution = 100
); I wasn't able to do it via |
Beta Was this translation helpful? Give feedback.
-
Although I have used I can confirm that @stefaneng's above approach works very well! I've simplified it a bit below: Labeling sub-plots when using
|
Beta Was this translation helpful? Give feedback.
Although I have used
cowplot::plot_grid
in the past to combine figures and label them (e.g. a,b,c,d), I recently ran into a scenario where this did not work and I needed to usecreate.multipanelplot
to combine the figures instead.I can confirm that @stefaneng's above approach works very well! I've simplified it a bit below:
Labeling sub-plots when using
create.multipanelplot
:Note if the plots you are combining are each multipanelplots, then you need to add class
multipanelplot
above