Place 8 parcels and a legend in the grid

I have 8 plots and one legend that I would like to place on a 3x3 grid so that all axes are aligned.

It works great when I don't include the legend in my grid, but as soon as I added the legend my plots change and no longer align.

plot_grid(SiO2TiO2, SiO2Al2O3, SiO2FeO, SiO2MgO, SiO2CaO, SiO2Na2O, SiO2K2O, SiO2P2O5, align=c("hv"),nrow = 3, ncol = 3)

      

Graphs aligned in a 3x3 grid with no legend:

plot_grid(SiO2TiO2, SiO2Al2O3, SiO2FeO, SiO2MgO, SiO2CaO, SiO2Na2O, SiO2K2O, SiO2P2O5, legend, align=c("hv"),nrow = 3, ncol = 3)

      

Warning messages:

1: In align_plots (plotlist = plot, align = align): Plots cannot be vertically aligned. Graph placement is uneven.

2: In align_plots (plotlist = plot, align = align): Plots cannot be horizontally aligned. Graph placement is uneven.

Plots are not aligned in a 3x3 grid with the caption:

Does anyone know how to align legend with graphs? Thanks in advance!

+3


source to share


1 answer


Perhaps you need to define the width of your graphs in the grid.arrange command.

As in the following example:



plot_grid(SiO2TiO2, SiO2Al2O3, SiO2FeO, SiO2MgO, SiO2CaO, SiO2Na2O, SiO2K2O, SiO2P2O5, legend, align=c("hv"), nrow = 3, ncol = 3, widths=c(2.3, 2.3, 2.3))

      

0


source







All Articles