I have a file with 3 cols as: x y value 1 1 0.5000 1 2 1.8333 1 3 4.3333 2 1 0.7500 2 2 0.7500 2 3 4 3 1 0.7500 3 2 1.4167 3 3 5.1667 I read them in using p <- read.table("data.txt", header=TRUE) My questoin: how to draw a image to show the values at different positions (x, y)? I would like to see different colors for different values. Sorry if it is a naive question, but it is my first week of R and I have been trying for several hours trying to make it. Thank you, -- Senlin Liang [[alternative HTML version deleted]]
with(p,plot(x,y,pch=20,col=1+as.integer(value))) -- Clint Bowman INTERNET: clint at ecy.wa.gov Air Quality Modeler INTERNET: clint at math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600 FAX: (360) 407-7534 Olympia, WA 98504-7600 On Fri, 20 Nov 2009, Senlin Liang wrote:> I have a file with 3 cols as: > x y value > 1 1 0.5000 > 1 2 1.8333 > 1 3 4.3333 > 2 1 0.7500 > 2 2 0.7500 > 2 3 4 > 3 1 0.7500 > 3 2 1.4167 > 3 3 5.1667 > > I read them in using > p <- read.table("data.txt", header=TRUE) > > My questoin: how to draw a image to show the values at different positions > (x, y)? I would like to see different colors for different values. > > Sorry if it is a naive question, but it is my first week of R and I have > been trying for several hours trying to make it. > > Thank you, >
Senlin Liang wrote:> I have a file with 3 cols as: > x y value > 1 1 0.5000 > 1 2 1.8333 > 1 3 4.3333 > 2 1 0.7500 > 2 2 0.7500 > 2 3 4 > 3 1 0.7500 > 3 2 1.4167 > 3 3 5.1667 > > I read them in using > p <- read.table("data.txt", header=TRUE) > > My questoin: how to draw a image to show the values at different > positions > (x, y)? I would like to see different colors for different values.Hi Senlin, Try this: library(plotrix) plot(p$x,p$y, col=color.scale(p$value,extremes=c("green","red")) Jim