# NOT RUN {
x<-sample(1:20,400,TRUE)
y<-sample(1:20,400,TRUE)
z<-runif(400,5,20)
xyz<-makeDensityMatrix(x,y,z,nx=20,ny=20,xlim=c(1,10),ylim=c(1,10),
geocoord=FALSE)
par(mar=c(7,3,2,3))
plot(0,xlim=c(1,10),ylim=c(1,10),type="n",xlab="",axes=FALSE)
box()
densityGrid(xyz,range.cex=c(1,4),xlim=c(1,10),ylim=c(1,10),
red=c(0,0.5,0.8,1),green=c(1,0.8,0.5,0),blue=0,pch=15)
color.legend(3,-0.7,7,-0.2,c(5,10,15,20),
rect.col=color.scale(1:4,cs1=c(0,0.5,0.8,1),cs2=c(1,0.8,0.5,0),cs3=0,alpha=1))
par(xpd=TRUE)
text(5,0.3,"Intensity")
points(c(3.5,4.5,5.5,6.5),rep(-1.7,4),pch=15,cex=1:4)
text(c(3.5,4.5,5.5,6.5),rep(-1.3,4),1:4)
text(5,-1,"Density")
par(xpd=FALSE)
# }
Run the code above in your browser using DataLab