[R-sig-Geo] Colouring hatch lines

Roger Bivand Roger.Bivand at nhh.no
Thu Apr 3 19:39:31 CEST 2008


On Thu, 3 Apr 2008, Mulholland, Tom wrote:

> I might be having finger problems, but I have been unable to get R to
> overlay coloured hatching on one of my plots.
>
> This code replicates my problem which I would have thought would have
> given me vertical yellow lines.
>
> require(maptools)
> require(classInt)
> columbus <- readShapePoly(system.file("etc/shapes/columbus.shp",
> package="spdep")[1])
> mypal <- c("wheat1", "red3")
> f5 <- classIntervals(columbus$CRIME, n=5, style="fisher")
> f5Colours <- findColours(f5, mypal)
> # or f5Colours <- c("red","green","blue") without classInt
> plot(columbus, col = f5Colours)
> plot(columbus[which(columbus$HOVAL > 40),], density = 15, angle = 0, add
> = TRUE)
> plot(columbus[which(columbus$HOVAL > 40),], density = 15, angle = 90,
> col = "yellow",add = TRUE)
>
> I am not that well versed with sp:::plot.SpatialPolygons but it looks to
> me as if it eventually uses the polygon command which suggests that
> 'col' will be used for the colour of the hatching if density is given.

Thanks for a very clear report. As things stand, the plot method for sp 
objects does not pass the col= argument through if density= is given. I'll 
try to fix this for the next release.

Roger

>
> Any help would be appreciated as I have exhausted my ideas for keywords
> to find any answers to the problem that are already on the list.
>
>
> I am using
> platform       i386-pc-mingw32
> arch           i386
> os             mingw32
> system         i386, mingw32
> status
> major          2
> minor          6.2
> year           2008
> month          02
> day            08
> svn rev        44383
> language       R
> version.string R version 2.6.2 (2008-02-08)
>
> Tom Mulholland
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list