I want to plot objects of class SpatialPolygons with a transparent filling color. Slightly changed example from the help pages of SpatialPolygons-Class:
# simple example, from vignette("sp"):
Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)
Srs1 = Polygons(list(Sr1), "s1")
Srs2 = Polygons(list(Sr2), "s2")
Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3)
plot(1,1,type="n",ylim=c(0,10),xlim=c(0,10),xlab="",ylab="",yaxt="n",xaxt="n")
plot(SpP, col = paste0(c("#FF0000","#00FF00","#0000FF"),"55"), pbg="white",add=TRUE)
works fine. However, if I want to zoom in, the SpatialPolygons-Class method of plot can't handle transparency anymore:
plot(1,1,type="n",ylim=c(0,7),xlim=c(0,7),xlab="",ylab="",yaxt="n",xaxt="n")
plot(SpP, col = paste0(c("#FF0000","#00FF00","#0000FF"),"55"), pbg="white",add=TRUE)
Is there a way to get this to work? (I want to keep the classical plot
function if possible)