[R] plot within a loop

Matthew Keller mckellercran at gmail.com
Wed Oct 24 17:30:49 CEST 2007


Hi Santanu,

You can write it out to a PDF:

a.new = 1.2
value.b = seq(from = 0, to = 1, by = 0.001)
pdf('MyGraphs.pdf',width=11, height=8.5,pointsize=12, paper='special')
par(mfrow = c(3,2))
for (i in 1:length(d)){
plot(value.b, dbeta(shape1 = value.b, shape2 = d[i], a.new), main =
paste("B[",i,"]"))}
dev.off()



On 10/24/07, Santanu Pramanik <spramanik at survey.umd.edu> wrote:
> Hi ,
>
> I'm having problem with the following plot. Basically I have to do
> 51(length of d, see below) plots. I want 6 plots (say) in a page and
> rests are in different pages. win.graph() starts a plot in new page. But
> I'm not being able to combine par(mfrow = c(3,2)) and win.graph() within
> a loop.
>
>
>
> > d
>  [1] 14.108 13.883 11.022 13.426  2.341  9.010 12.868 15.603 30.810
> 3.931 11.825 16.195 10.267  3.862  8.743  8.958 11.505
> [18] 13.015 16.701 13.159 12.211  6.219  4.863  7.736 15.876 12.964
> 14.066  7.423  9.824  8.002  5.279 11.688  3.051  6.702
> [35]  9.806  3.989 13.989 11.007  3.678 14.616 16.174 15.783 12.014
> 3.318  8.642 11.179 10.941 10.142 15.515 10.075  9.117
> >
>
> ## plot of B_i
> a.new = 1.2
> par(mfrow = c(3,2))
> value.b = seq(from = 0, to = 1, by = 0.001)
> for (i in 1:length(d)){
> plot(value.b, dbeta(shape1 = value.b, shape2 = d[i], a.new), main =
> paste("B[",i,"]"))
> }
>
> Any help, comments would be gratefully acknowledged. Thanks in
> advance,
> Santanu
>
> --------------------------------------------------------------------
> Santanu Pramanik
> JPSM, 1218J Lefrak Hall
> University of Maryland, College Park
> Phone: 301-314-9916
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>


-- 
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.com



More information about the R-help mailing list