[R-sig-Geo] [R] adding text to spplot

Matevž Pavlič matevz.pavlic at gi-zrmk.si
Wed Jul 13 17:18:14 CEST 2011


Hi,
still have troubles,  if I have a code like this :

spplot(enaD2, "var1.pred",sp.layout=pts,  main = "globina 60 cm", sub="D2", col.regions=terrain.colors(64), contour=T)

i get a nice plot with contours but without text.

If ia use your code :

spplot(enaD2, "var1.pred",sp.layout=pts,  main = "globina 60 cm", sub="D2", col.regions=terrain.colors(64), contour=T, panel = function(x,y,z,...) { sp.points(ena, pch=20, cex=1.5, col="red")
sp.text(coordinates(ena), ena$ime) }    )

I get eeverything else but the actual spplot (just points and labels and a key on the right).

any ideas?

m

-----Original Message-----
From: Weidong Gu [mailto:anopheles123 at gmail.com] 
Sent: Wednesday, July 13, 2011 4:03 PM
To: Matevž Pavlič
Cc: r-help at r-project.org; r-sig-geo at r-project.org
Subject: Re: [R] adding text to spplot

You may need panel function

spplot(enaD2, "var1.pred",sp.layout=pts, main = "globina 60 cm", sub="D2", col.regions=terrain.colors(64), contour=T, panel = function(x,y,z,subscripts,...) {
panel.polygonsplot(x,y,z,subscripts,...)
sp.text(coordinates(enaD2), enaD2$ime[subscripts]) }


HTH

Weidong Gu

On Wed, Jul 13, 2011 at 7:31 AM, Matevž Pavlič <matevz.pavlic at gi-zrmk.si> wrote:
> hi all,
>
>
>
> I have a plot to which i would like to add text labels. And i cant find a way...here is the code :
>
>
>
> enaD2<-idw(D2~1, loca=dva, newdata=grd)
>
> pts = list("sp.points",  dva,  pch = 20, cex=1.5, col = "darkred
>
> spplot(enaD2, "var1.pred",sp.layout=pts, main = "globina 60 cm", 
> sub="D2", col.regions=terrain.colors(64), contour=T)
>
>
>
>
>
> text information is in ena$ime field,
>
>
>
> regards, m
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>


More information about the R-sig-Geo mailing list