R Multiples plot in a single varible

后端 未结 1 416
忘了有多久
忘了有多久 2021-01-23 15:35

Hi I have the next code:

par(mfrow=c(1,3))
plot(BCxyz[,1], BCxyz[,2], main=\"Bray-Curtis 1:2\", pch=20, cex = 3, col=c(\"blue\", \"green\", \"red\", \"yellow\")         


        
1条回答
  •  离开以前
    2021-01-23 15:52

    You can use recordPlot to save the current plot and recall it later.

    par(mfrow=c(1,3))
    plot(1) ; plot(2); plot(3)
    figure1 <- recordPlot()
    # view then close the plot window, just to prove that redrawing it works
    
    figure1             # redraws it when interactive on the console
    replayPlot(figure1) # same thing
    print(figure1)      # indirect, calls replayPlot
    

    The last two commands have the same result on the console, but if you are going to "replay" the plot programmatically (e.g., within {...} code-blocks or functions), you should use the replayPlot function directly. The reason just figure1 works by itself on the console (no print or replayPlot) is that figure1 is of class "recordedplot", and the base-R grDevices:::print.recordedplot S3 method calls replayPlot directly.

    0 讨论(0)
提交回复
热议问题