[R] Using subplot (from Hmisc) along with par(mfrow)

Cory Champagne cory.champagn at gmail.com
Thu Jul 3 21:45:51 CEST 2014


   Hello all,
   I think this should be a relatively easy solution involving par but I can't
   figure it out, involving subplot:
   I'm  making  a  three-figure plot, each with a subplot.  Here's simple
   reproducible code below.  But each plot seems to call the original par
   setting and redraws the new plot in the first position, rather than adding
   subsequent plots in a single plot window.
   Can someone tell me how to fix this so the result is three figures, each
   containing a subplot, all within a single plot window?
   Thanks,
   -Cory
   library(Hmisc)    # subplot from the Hmisc package
   par(mfrow=c(3,1) )    # set mfrow for 3 rows and 1 column.
   plot(1:10, 1:10, main = "Plot 1")
       subplot(plot(10,10, xlab="", ylab=""), x=2, y=8, size = c(0.5, 0.5) )
   plot(11:20, 11:20, main = "Plot 2")
       subplot(plot(10,10, xlab="", ylab=""), x=12, y=18, size = c(0.5, 0.5)
   )
   plot(21:30, 21:30, main = "Plot 3")
       subplot(plot(10,10, xlab="", ylab=""), x=22, y=28, size = c(0.5, 0.5)
   )


More information about the R-help mailing list