15.3.4 Fuzzy Methods

# Fig. 15.6.: Fuzzy clustering
library(StatDA)
data(moss)
data(kola.background)

el=c("Cu","Ni","Mg","Sr")
x=scale(log10(moss[,el]))

set.seed(100)
res=cmeans(x,4)

X=moss[,"XCOO"]
Y=moss[,"YCOO"]
# true representation of x and y axis of map for plot
xwid=diff(range(X))/12e4
ywid=diff(range(Y))/12e4

pdf("fig-15-6.pdf",width=2*xwid,height=2*ywid)
par(mfrow=c(2,2),mar=c(1.5,1.5,1.5,1.5))

# NEW MAP
plot(X,Y,frame.plot=FALSE,xaxt="n",yaxt="n",xlab="",ylab="",type="n")
plotbg(map.col=c("gray","gray","gray","gray"),add.plot=T)
points(moss[,"XCOO"],moss[,"YCOO"],col=gray(1-res$mem[,1]),pch=15,cex=1)

# Legend
text(752000,7880000,"Cluster 1",cex=1.1)

# scalebar
scalebar(761309,7373050,861309,7363050,shifttext=-0.5,shiftkm=37e3,sizetext=0.8)
# North arrow
Northarrow(362602,7818750,362602,7878750,362602,7838750,Alength=0.15,Aangle=15,Alwd=1.3,Tcex=1.6)


# NEW MAP
plot(X,Y,frame.plot=FALSE,xaxt="n",yaxt="n",xlab="",ylab="",type="n")
plotbg(map.col=c("gray","gray","gray","gray"),add.plot=T)
points(moss[,"XCOO"],moss[,"YCOO"],col=gray(1-res$mem[,2]),pch=15,cex=1)

# Legend
text(752000,7880000,"Cluster 2",cex=1.1)

# scalebar
scalebar(761309,7373050,861309,7363050,shifttext=-0.5,shiftkm=37e3,sizetext=0.8)
# North arrow
Northarrow(362602,7818750,362602,7878750,362602,7838750,Alength=0.15,Aangle=15,Alwd=1.3,Tcex=1.6)


# NEW MAP
plot(X,Y,frame.plot=FALSE,xaxt="n",yaxt="n",xlab="",ylab="",type="n")
plotbg(map.col=c("gray","gray","gray","gray"),add.plot=T)
points(moss[,"XCOO"],moss[,"YCOO"],col=gray(1-res$mem[,3]),pch=15,cex=1)

# Legend
text(752000,7880000,"Cluster 3",cex=1.1)

# scalebar
scalebar(761309,7373050,861309,7363050,shifttext=-0.5,shiftkm=37e3,sizetext=0.8)
# North arrow
Northarrow(362602,7818750,362602,7878750,362602,7838750,Alength=0.15,Aangle=15,Alwd=1.3,Tcex=1.6)


# NEW MAP
plot(X,Y,frame.plot=FALSE,xaxt="n",yaxt="n",xlab="",ylab="",type="n")
plotbg(map.col=c("gray","gray","gray","gray"),add.plot=T)
points(moss[,"XCOO"],moss[,"YCOO"],col=gray(1-res$mem[,4]),pch=15,cex=1)

# Legend
text(752000,7880000,"Cluster 4",cex=1.1)

# scalebar
scalebar(761309,7373050,861309,7363050,shifttext=-0.5,shiftkm=37e3,sizetext=0.8)
# North arrow
Northarrow(362602,7818750,362602,7878750,362602,7838750,Alength=0.15,Aangle=15,Alwd=1.3,Tcex=1.6)

dev.off()