[R] how to label multiple plots

Jim Lemon jim at bitwrit.com.au
Sun Nov 25 06:43:41 CET 2007


G Ilhamto wrote:
> Dear R-list,
> 
> I want to combine several plots in one graph.
> I did this: plot(a1); plot(a2, add=TRUE); ...plot(a5, add=TRUE)
> The problem is the more plot we put, the more complex the graph.
> Is there any way to label each line; or other way just to make sure I know
> which one which?
> 
Hi Ilham,
At a guess, you want to distinguish the points, lines or other elements 
that represent a1, a2, ...

You can use different symbols for the points (pch=...),
different colors (col=...) for the lines or circles or rectangles,
different line types (lty=...) for the lines,...

plot(1:10)
points(1:10+0.2,rnorm(10)+5,pch=2)
lines(1:10-0.2,sample(1:10,10),col="green")

Jim



More information about the R-help mailing list