[R] x y plot with z coordinate scaling to a color value
Paul Hiemstra
p.hiemstra at geo.uu.nl
Wed May 19 12:49:22 CEST 2010
Hi Jannis,
You can have a look at image(), or alternatively look at spplot. The
latter assumes that you have your data structured according to the
spatial R classes that the sp-package provides:
library(sp)
data(meuse.grid)
head(meuse.grid)
summary(meuse.grid)
# transform to sp-object
gridded(meuse.grid) = ~x+y
summary(meuse.grid)
spplot(meuse.grid, "dist")
cheers,
Paul
On 05/19/2010 12:24 PM, Jannis wrote:
> Dears,
>
> before I start programming my own function I would like to ask you whether there is any function already available that lets me plot a x/y plot with the colors of the points determined by scaling a third variable z into a defined colorramp?
>
> Until now I am using a wild combination of functions to create a colorvector by hand, then calling
>
> plot(x,y,col=colors)
>
> and then using color.legend() from plotrix to add a colorbar. Is there anything where I can just call (for example)
>
> plot(x,y,z)
>
>
> and get a plot and a colorbar next to it?
>
> If not I have to program that myself because my current way involves a lot of steps and readjusting plotting regions.
>
>
> Thanks for your help!
>
> Jannis
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +3130 274 3113 Mon-Tue
Phone: +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
More information about the R-help
mailing list