Closed malisas closed 7 years ago
Last time I did something like this, I plot the heatmap to screen, then save it to an object using hmap_fig = grid.grab(wrap=TRUE)
. Then that can be combined with other ggplot figures using cowplot
and wrapping hmap_fig
in arrangeGrob()
. I'm sure there's a better way, but this worked for me.
Thanks @gfinak .
grid.grab()
helped so that I don't need to modify plot.COMPASSResult
to get something compatible with plot_grid()
.
plot(compassResult, show_rownames = FALSE,
main = "Heatmap of Mean Probability of Response",
fontsize=14, fontsize_row=13, fontsize_col=11)
hmap_fig <- grid.grab(wrap=TRUE)
# How to proceed?
hmap_fig_ag <- arrangeGrob(hmap_fig, example_plot, widths = c(2,1))
hmap_fig_ag_g <- grid.arrange(hmap_fig_ag, ncol=1)
plot_grid(hmap_fig_ag_g, labels = "A")
I am having trouble figuring out the correct parameters to pass to arrangeGrob()
/grid.arrange()
/ plot_grid()
. I still get a plot like the one I posted above, where the two plots are on top of each other. Did you need to set the margins or plot size somehow?
plot_grid(example_plot,arrangeGrob(hmap_fig),labels=c("A","B"))
Thanks, that almost fixes it except for the "B" panel label in the wrong place...I guess I'll look into other solutions, maybe Inkscape?
You can adjust the location of the labels in plot_grid(). Read the docs on that function, they are helpful.
Thank you, that helps.
I have a COMPASS heatmap I would like to display in a figure with some other plots, like the figure shown here from this paper: I am curious how the figure was created. This is the closest I can get using cowplot and some example data:
This required modifying
plot.COMPASSResult
to return the final heatmap as agrob
and then turning it into a gtable to make compatible with cowplot. As you can see, the plot positions are still all bungled and I'm not sure how to make it look neat. If I doshow_rownames = TRUE
it looks even worse.Is there an easy solution using R? If not, I could perhaps save the heatmap as an svg and then put together a figure using some other software...?