Search code examples
rpsych

How to show Two Graphs of psych package side by side


The Code below should show Two Identical Graphs side by side. However, it is plotting 2nd graph over the 1st.

library("psych")
par(mfrow = c(1, 2))
corPlot(mtcars)
corPlot(mtcars)

This is minimum working example. Actual Graphs are different.

Edit: As shown in the answer, following works

par(mfrow = c(1, 2))
corPlot(mtcars, show.legend = FALSE, keep.par = FALSE)
corPlot(mtcars, show.legend = FALSE, keep.par = FALSE)

Solution

  • In the help-page from corPlot there is actual a working example two plot several graphs, here it is adapted for your data:

    op <- par(mfrow=c(1,2))
    corPlot(mtcars,show.legend=F,keep.par=FALSE,upper=T)
    corPlot(mtcars,show.legend=F,keep.par=FALSE,upper=T)
    par(op)
    

    enter image description here

    Note, that when you change show.legend=T, this does not work.