[R] Colour gradients and colour fill between points
Greg Snow
538280 at gmail.com
Mon Aug 20 18:48:28 CEST 2012
The akima package does interpolation and there are probably others as well.
You could also fit a parametric, semi-parametric, or local model to
the observed data and use the predicted values from the model for the
interpolations (see the loess function for one option that might work
well for you).
You could also use the rasterImage function rather than levelplot, it
has options to do interpolation.
On Mon, Aug 20, 2012 at 8:01 AM, Richard Müller
<mueller.eisborn at googlemail.com> wrote:
> Hello,
> Can somebody help me on a colour question?
> I have a levelplot made with the following syntax:
>
> library(lattice)
> inp <- read.csv("hoenne1", header = TRUE)
> levelplot(z~x*y, data = inp, region = TRUE, pretty = TRUE, col.regions
> = terrain.colours)
>
> The file "hoenne1" contains the data. I'll give a short example:
> x,y,z
> 0,0,1
> 0,1,1
> 0,2,1
> 1,0,2
> 1,2,2
> 0,2,2
> 1,2,3
> 2,2,2
>
> You see that data point 1,1 is missing. My script therefore produces
> an "empty" field.
> I want the following: the colours should be distributed as
> interpolating gradients. The empty hole in the middle should get the
> colour for z = 2 because that's the result when interpolating. Also
> the rest of the graph should be produced by interpolating, i.e.
> between 0,0 and 0,1 (z=1 resp. z=2) should be the colour for z = 1.5,
> so that a really smooth gradient is achieved. Is that possible?
>
>
> Thanks for helping, Richard
>
> --
> Richard Müller . Am Spring 9 . D-58802 Balve
> www.oeko-sorpe.de
>
> ______________________________________________
> 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.
--
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com
More information about the R-help
mailing list