[R] graphics::plot Organizing line types, line colors and generating matching legends...

Ralf B ralf.bierig at gmail.com
Mon May 10 21:29:15 CEST 2010


Lets say I have a generated data frame with variables that follow a
naming convention:

title,a1,a2,b1,b2,b3,c1,c2,c3,c4...

I am plotting every column (starting from a1) as a line in a plot.
That works. However my diagram becomes very unorganized. Creating
legends is nice, but trying out different combinations requires me to
adjust my legend since it is generally disconnected from the data.

Is there an elegant way where R generates legends for its variables so
that the legend will fit the line and uses the column name as in the
legend? I guess I am asking for the basic Excel thing. I understand
that in the standard graphics package, this is not really intended.
Perhaps somebody can point me into a direction where this more easily
possible? Is it for example easier in gplot or lattice?

Ralf



More information about the R-help mailing list