[R-sig-Geo] Plotting data with multiple symbols and colours
ONKELINX, Thierry
Thierry.ONKELINX at inbo.be
Wed Mar 14 14:15:46 CET 2007
Hi Edzer,
Thanks for your suggestions. Bubble() looks nice, but we are trying to
mimic the output from GSLIB. We're comparing R vs GSLIB, surfer and
VarioWin as a task in a course on spatial statistics. Our motto is:
"This is R. There is no if. Only how. (Simon Blomberg)" That's why we we
prefer your spplot solution.
The new code is:
library("sp")
library("RColorBrewer")
library("lattice")
set.seed(1)
Error <- SpatialPointsDataFrame(matrix(runif(1000), ncol = 2), data =
data.frame(error = runif(500, -10, 10)))
Error$sign <- sign(Error$error)
Error$abs <- abs(Error$error)
trellis.par.set(sp.theme(set = FALSE, regions = list(col =
rev(rainbow(50, start = 0, end = 4/6)))))
spplot(Error, zcol = "abs", pch = ifelse(Error$sign < 0, 95, 3),
key.space = "right", cuts = 0:10)
This is pretty much what we wanted. Except for the changes in pch in het
key. But I'll dig into xyplot and the source of spplot.
Thanks again,
Thierry
------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be
Do not put your faith in what statistics say until you have carefully
considered what they do not say. ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney
> -----Oorspronkelijk bericht-----
> Van: Edzer J. Pebesma [mailto:e.pebesma at geo.uu.nl]
> Verzonden: woensdag 14 maart 2007 13:40
> Aan: ONKELINX, Thierry
> CC: r-sig-geo at stat.math.ethz.ch
> Onderwerp: Re: [R-sig-Geo] Plotting data with multiple
> symbols and colours
>
> I would try the alternative,
>
> bubble(Error,maxsize=1.5)
> bubble(Error,maxsize=1.5, key.entries=-10:10)
>
> Doing what you want with spplot, you're basically thrown back
> at xyplot with asp="iso"; look at how key is formed there; with
>
> spplot(Error, pch = ifelse(Error$error < 0, 95, 3), key.space
> = "right", cuts = -10:10)
>
> I get funny pch changes in the key. I think that spplot
> passes an optional key argument to xyplot.
> --
> Edzer
>
> ONKELINX, Thierry wrote:
> > Dear listeRs,
> >
> > We're trying to create a map with interpolation errors of
> some spatial
> > data. The idea is to plot the errors at the location of the
> data, with
> > a "+" or "-" symbol to indicate whether they are positive
> or negative
> > and a colour ramp that indicates the magnitude of the
> error. For now,
> > we managed to get a plot with the correct symbols. But the
> colour ramp
> > only works for the positive errors. The code to generate this:
> >
> > library("sp")
> > library("RColorBrewer")
> > library("lattice")
> > set.seed(1)
> > Error <- SpatialPointsDataFrame(matrix(runif(1000), ncol =
> 2), data =
> > data.frame(error = runif(500, -10, 10)))
> trellis.par.set(sp.theme(set
> > = FALSE, regions = list(col = c(rainbow(50, start = 0, end = 4/6),
> > rev(rainbow(50, start = 0, end = 4/6))))))
> spplot(Error[Error$error >=
> > 0, ], zcol = "error", sp.layout = list("sp.points",
> Error[Error$error
> > < 0, ], pch = 95), key.space = "right", cuts = seq(-10, 10,
> length =
> > 21), pch = 3)
> >
> > The questions:
> > 1. For do we set the colour ramp for the negative values?
> > 2. Can we change the key so it displays only absolute
> values or "-" in
> > front of the negative values?
> >
> > All help is welcome.
> >
> > Thierry
> >
> >
> ----------------------------------------------------------------------
> > --
> > ----
> > ir. Thierry Onkelinx
> > Instituut voor natuur- en bosonderzoek / Reseach Institute
> for Nature
> > and Forest Cel biometrie, methodologie en kwaliteitszorg / Section
> > biometrics, methodology and quality assurance Gaverstraat 4 9500
> > Geraardsbergen Belgium tel. + 32 54/436 185
> Thierry.Onkelinx at inbo.be
> > www.inbo.be
> >
> >
> > Do not put your faith in what statistics say until you have
> carefully
> > considered what they do not say. ~William W. Watt A statistical
> > analysis, properly conducted, is a delicate dissection of
> > uncertainties, a surgery of suppositions. ~M.J.Moroney
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>
More information about the R-sig-Geo
mailing list