[R] labels in multiple plot
Greg Snow
Greg.Snow at imail.org
Mon May 19 22:31:38 CEST 2008
Try:
> m <- matrix( rnorm(30, rep(c(10,12,15), 10)), nrow=3 )
>
> matplot(y=t(m), pch= rep(19:21, 10), type='b', col=c('red','green','blue'))
> legend('bottomright', legend=c('ABC','DEF','GHI'), pch=19:21,
+ col=c('red','green','blue'))
>
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111
> -----Original Message-----
> From: Bruno C. [mailto:bruno.c at inwind.it]
> Sent: Monday, May 19, 2008 1:49 PM
> To: Greg Snow
> Cc: deepayan.sarkar; price_ja; r-help
> Subject: RE: [R] labels in multiple plot
>
> Yep sorry
> I need to use the legend command but am not so good at:
> Given this pseudo-code:
> point_type<-c("black","gray20","red"....)
> ...
> for (i in 1:dim(m)[1]) {
> par(pch=(18+i))
> par(fg=point_type[i])
> plot(m[i,], type='b', ylim = c(lower,
> upper), type = "l", ...)
> legend( ???? , legend=rownames(m)[i] ,pch=(18+i)
> par(new=T)
> }
> I want a singlebox appear in the plot, containing the legend;
> each line of the legend contains the pch and a name
>
> Thanx
>
> > It is not clear what exactly you are trying to do, but you
> may want to look at ?matplot for an alternative to your loop,
> then look at ?legend for adding explanations.
> >
> > Hope this helps,
> >
> > --
> > Gregory (Greg) L. Snow Ph.D.
> > Statistical Data Center
> > Intermountain Healthcare
> > greg.snow at imail.org
> > (801) 408-8111
> >
> >
> >
> > > -----Original Message-----
> > > From: r-help-bounces at r-project.org
> > > [mailto:r-help-bounces at r-project.org] On Behalf Of Bruno C.
> > > Sent: Monday, May 19, 2008 9:21 AM
> > > To: deepayan.sarkar
> > > Cc: price_ja; r-help
> > > Subject: [R] labels in multiple plot
> > >
> > >
> > > My code is the following:
> > >
> > > point_type<-c("black","gray20","red"....)
> > > ...
> > > for (i in 1:dim(m)[1]) {
> > > par(pch=(18+i))
> > > par(fg=point_type[i])
> > > plot(m[i,], type='b', ylim = c(lower,
> upper), type =
> > > "l", ...)
> > > par(new=T)
> > > }
> > >
> > > Now I need to add an 'explanation' to each pch.
> > > I would have a box in the upperright corner of the plot
> containing
> > > several rows each one in the format:
> > > 'pch symbol': 'explanation'
> > >
> > > How can I do that?
> > >
> > > Thanx
> > > Bruno
> > >
> > > ______________________________________________
> > > 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.
> > >
> >
> >
>
>
More information about the R-help
mailing list