[R] Plot multiple columns

Ivan Calandra ivan.calandra at uni-hamburg.de
Tue Jun 1 11:49:05 CEST 2010


Hi,

Try with:
par(mfrow=c(11,2))

It should work better!
Remember that mfrow is an argument of the function par(), not a function 
itself.

One other tip: think about using pdf, ps, png, or SVG devices, I find it 
easier and nicer.

HTH,
Ivan

Le 6/1/2010 10:02, Noah Silverman a écrit :
> 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!
>
> ______________________________________________
> 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.
>
>    

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php



More information about the R-help mailing list