[R-sig-Geo] graphical doubts: lines colour, order objects and print in only one graph
Edzer J. Pebesma
e.pebesma at geo.uu.nl
Tue May 15 17:16:25 CEST 2007
Marta Rufino wrote:
> Dear list members,
>
>
> I have three doubts: :-)
>
> 1. How to colour the lines from a shape file (which has been inserted
> into a spplot, through sp.layout):
>
> #For example
> nc <- readShapeLines("costa.shp", proj4string=CRS("+proj=longlat
> +datum=WGS84"))
> spplot(grid[1], sp.layout=list(nc))
> #How do I indicate the colour of the lines in the graph? Sorry I dont
> give a real example... was unable to find shp+gridded data to fit in
>
>
try passing sp.layout = list(sp.lines, nc, col = 'red')
> 2. How to include a dataframe with text into spplot (i.e. several text
> positions in the graph). I managed to do it for one point, but not for
> many at the same time. Is it possible?
>
> data(meuse.grid); coordinates(meuse.grid) = c("x", "y");
> gridded(meuse.grid) = TRUE #insert data
> tx1=data.frame(t(bbox(coordinates(meuse.grid))), lab=c("Bom dia","Boa
> tarde"))#text labels to plot, for example...
> tx1 = list("sp.text", loc=tx1[1,1:2], tx1$lab[1] ,col = "brown", cex=.5,
> pos=3)
> spplot(meuse.grid, sp.layout=list(tx1)) #map... works because it is only
> one label
>
> tx1=data.frame(t(bbox(coordinates(meuse.grid))), lab=c("Bom dia","Boa
> tarde"))#text labels to plot, for example...
> tx1 = list("sp.text", loc=tx1[,1:2], tx1$lab ,col = "brown", cex=.5, pos=3)
> spplot(meuse.grid, sp.layout=list(tx1)) #map... does not work
>
>
I think it now only works one label at a time; would be nice if it
worked for vectors, will look at it. Have a look at example(spplot) for
an example.
> 3. How do I define that the lines/text should only appear in the first
> plot (if I have multiple plots)?
> spplot(meuse.grid, sp.layout=list(tx1)) # If I wanted that the labels
> only appear in the soil plot, not in the others
>
Add a which=n with n the panel number to the list for the label.
--
Edzer
More information about the R-sig-Geo
mailing list