strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science

Home Page:https://strengejacke.github.io/sjPlot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

saving multiple plots with save_plot()

dfareri opened this issue · comments

Hi, I have a few questions regarding the usage of save_plot() with plot_model. I have run a mixed effects regression model using glmer includes 2 different interaction terms (e.g., age x within-subject variable 1, within-subject variable 1 * within-subject variable 2). When I run this using plot_model to plot the interaction terms, both of which are significant, I obviously get two plots. However, I'm curious about two things.

First, is it possible to have the two plots generated with different titles and different axis titles for the different interactions within the model?

Second, if I want to save both plots using the save_plot() function, is there a way to specify anything other than just the last plot that was generated? it seems that all I can call is save_plot('filename.png',fig=last_plot()...)--is there a way to have a different setting for fig = in order to save the other interaction plot from the model? Apologies if this is a stupid question, I have been working most recently in python but need to come back to R for an old dataset in which I was using this package and ggplot, and I am kind of rusty.

Thank you in advance,
Dominic

Hi Dominic,

Yes, you can combine plots as follows. Create an object containing three plots, then save using ggsave.

Cheers,

p <- p1 + p2 + p3

 ggsave("Primary_1.bmp",
        plot = p,
        width = 24,
        height = 14,
        units = "cm",
        dpi = 1200,
        bg = "transparent")