[R] Plot multiple columns

From: Noah Silverman <noah_at_smartmediacorp.com>
Date: Tue, 01 Jun 2010 01:02:52 -0700

I'm running a long MCMC chain that is generating samples for 22 variables.

I have each run of the chain as a row in a matrix.

So: Chain[,1] is the column with all the samples for variable one. Chain[,2] is the column with all the samples for variable 2, etc.

I'd like to fit all 22 on a single page to print a nice summary. It is OK if the graphs are small, I just need to show the overall shape and convergence.

Using par(mfrow=(11,2)) gives me the error: "figure margins too large" when I try to draw a plot
I looked at the Lattice package, which seems very promising, but I can't figure out how to have it plot each column in a separate box.

I need to do this same "one page" summary about 50 times, so it would be a nightmare to make over 1,000 plots by hand.

Ideally, I'd create a loop for each of the 50 runs that would generate a single page containing the 22 plots.

In pseudocode:

for( i in 1:50){

    for(j in 1:22){

        plot(Chain[,j], type="l")

BUT, this doesn't work.

Does anyone have any ideas about an easy way to do this?


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. Received on Tue 01 Jun 2010 - 08:06:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Jun 2010 - 18:40:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive