[R] Plot multiple columns
Noah Silverman
noah at smartmediacorp.com
Tue Jun 1 10:02:52 CEST 2010
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){
par(mfrow(11,2))
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?
Thanks!
More information about the R-help
mailing list