[R] using image to show RGB image data ?
hadley wickham
h.wickham at gmail.com
Tue Feb 5 04:34:13 CET 2008
> I'm now using image() to show image data (in my case dumps of SOM
> weights) but would like to show RGB colour data, not just single "z"
> colour values.
You can do this fairly readily with ggplot2:
install.packages("ggplot2")
library(ggplot2)
qplot(x, y, data=mydata, fill=rgb, geom="tile") + scale_fill_identity()
(assuming that your variable containing the rgb colour is called rgb)
If your data is originally in the matrix form used by image, see the
examples on http://had.co.nz/ggplot2/geom_tile.html on how to change
to the data.frame form used by ggplot.
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list