[R] how to draw image of a data distribution? Thanks

Jim Lemon jim at bitwrit.com.au
Sat Nov 21 12:14:18 CET 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.
Hi Senlin,
Try this:

library(plotrix)
plot(p$x,p$y,
  col=color.scale(p$value,extremes=c("green","red"))

Jim




More information about the R-help mailing list