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

Greg Snow 538280 at gmail.com
Sat Jul 5 19:10:33 CEST 2014


The subplot function in the TeachingDemos package is more up to date
than the version in Hmisc (the Hmisc version is a copy of an earlier
version of the one in TeachingDemos).  If you replace library(Hmisc)
with library(TeachingDemos) (with a recent version of TeachingDemos
installed) then the code works as you expect.

On Thu, Jul 3, 2014 at 1:45 PM, Cory Champagne <cory.champagn at gmail.com> wrote:
>
>    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)
>    )
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list