[R] changing pen mode [or adjusting for overlapping points?]

Marc Schwartz mschwartz at medanalytics.com
Tue Mar 11 21:58:21 CET 2003

>-----Original Message-----
>From: r-help-bounces at stat.math.ethz.ch 
>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Don Armstrong
>Sent: Tuesday, March 11, 2003 2:08 PM
>To: r-help at stat.math.ethz.ch
>Subject: [R] changing pen mode [or adjusting for overlapping points?]
>I'm ploting a rather large number of points [~24,000] in two 
>series with slightly different distributions.
>I would like to be able to effectively see where the two 
>distributions overlap by setting the pen mode (or it's 
>equivalent) to allow the overlapping portion to show up as a 
>different color (or different shade).
>Unfortunatly, I couldn't find an option in par or postscript 
>that looks like it would be of use.
>Ideas or suggestions?
>Don Armstrong

I may be mis-understanding what you are trying to do, but if you are
using plot() to generate a scatter plot (as opposed to a density plot)
and there are actual overlapping points between the two sets, you
could use jitter() to introduce some random noise into the plotted

Something like this might work, presuming that (x1, y1) and (x2, y2)
are your two sets of points:

> plot(x1, y1, pch = 16, col = "red")
> points(jitter(x2), jitter(y2), pch = 16, col = "blue")

The first plot() draws the initial set of data and points() adds the
second set of data to the same plot, but in a different color with
some random noise added to the points.

If that is not what you need, let us know.

Marc Schwartz

More information about the R-help mailing list