[R] Having a plot with points and line with different colors

Jim Lemon jim at bitwrit.com.au
Wed Mar 5 11:02:58 CET 2014


On 03/05/2014 08:59 PM, Baro wrote:
> Hi experts
>
> I want to have a plot, which consist of line and points something like this:
>
> plot(data, type="o")
>
> but I would like that lines and point have different colors. for example
> line should be blue and points should be black
>
> how can I do that in R?
>
Hi Baro,
There are a few ways to do this, here are two. Probably the easiest is 
to plot the lines, then add the symbols with "points", allowing the line 
to have one color and the point another.

You can overplot the "o" type of plot with points of a different color, 
but this occasionally leads to color bleed on the points if the 
overplotting is not exact.

Jim




More information about the R-help mailing list