Message-ID: <4E88C1BB.2030106@gmail.com>
Date: 2011-10-02T19:55:39Z
From: Duncan Murdoch
Subject: Scatterplot with the 3rd dimension = color?
In-Reply-To: <d6bb5191-52c5-402d-b527-ec8eb3e35783@h34g2000yqd.googlegroups.com>
On 11-10-02 1:11 PM, Kerry wrote:
> I have 3 columns of data and want to plot each row as a point in a
> scatter plot and want one column to be represented as a color gradient
> (e.g. larger values being more red). Anyone know the command or
> package for this?
It's not a particularly effective display, but here's how to do it. Use
rainbow(101) in place of rev(heat.colors(101)) if you like.
x <- rnorm(10)
y <- rnorm(10)
z <- rnorm(10)
colors <- rev(heat.colors(101))
zcolor <- colors[(z - min(z))/diff(range(z))*100 + 1]
plot(x,y,col=zcolor)
Duncan Murdoch