Re: [R] plotting many line segments in different colors

From: Marc Schwartz <>
Date: Sat 03 Jul 2004 - 07:44:33 EST

On Fri, 2004-07-02 at 16:33, rif wrote:
> I want to plot a large number of line segments, with a color
> associated with each line segment (I'm actually plotting a function of
> the edges of a 2d graph, and I want to use color to indicate the level
> of the function.) I originally thought I could use lines, but lines
> puts all its lines in one color (from help(lines), "col: color to use.
> This can be vector of length greater than one, but only the first
> value will be used.").
> Is there a function that does what I want? Right now I'm using the
> obvious solution of calling lines in a loop with a single segment, but
> this is really quite slow for my purposes, as I have several thousand
> lines total to plot.

Take a look at ?matplot or ?matlines depending upon which one might make sense for your particular application. Both functions are on the same help page.

HTH, Marc Schwartz mailing list PLEASE do read the posting guide! Received on Sat Jul 03 07:47:35 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:39 EST