Npoints = 20
myPoints = SpatialPointsDataFrame(
cbind(runif(Npoints), 51+runif(Npoints)),
data=data.frame(y1=c(NA, rnorm(Npoints-1)),
y2=c(sample(0:5, Npoints-1,replace=TRUE), NA)),
proj4string=CRS(
"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
)
)
mymap = openmap(myPoints)
breaks = c(-100, -1, 1, Inf)
thecol = c('red','orange','blue')
map.new(myPoints)
plot(mymap,add=TRUE)
plot(myPoints,col = as.character(cut(
myPoints$y1, breaks, thecol
)),add=TRUE)
scaleBar(myPoints, "bottomright",cex=1.25, scale.cex=2)
temp=legendBreaks("topleft", legend=breaks, col=thecol)
insetMap(myPoints, "bottomleft",col='blue')
Run the code above in your browser using DataLab