5.9.4 Incorrect Scaling of Symbol Size

# Fig. 5.14.: Map with wrong symbol size
library(StatDA)
data(chorizon)
data(kola.background)
el=chorizon[,"As"]
X=chorizon[,"XCOO"]
Y=chorizon[,"YCOO"]


# true representation of x and y axis of map for plot
xwid=diff(range(X))/12e4
ywid=diff(range(Y))/12e4

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


### NEW MAP: EDA 5 symbols

# generate plot with background
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)

SymbLegend(X,Y,el,type="boxplot",qutiles<-c(0,0.05,0.25,0.75,0.95,1),symbtype="EDA",symbmagn=0.8,
leg.position="topright",leg.title="As [mg/kg]",leg.title.cex=1.0,leg.round=2,leg.wid=4,
leg.just="right",cex.scale=0.85,xf=9e3,logscale=TRUE,accentuate=FALSE)

# 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: EDA 5 symbols, too small

# generate plot with background
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)

SymbLegend(X,Y,el,type="boxplot",qutiles<-c(0,0.05,0.25,0.75,0.95,1),symbtype="EDA",symbmagn=0.4,
leg.position="topright",leg.title="As [mg/kg]",leg.title.cex=1.0,leg.round=2,leg.wid=4,
leg.just="right",cex.scale=0.85,xf=9e3,logscale=TRUE,accentuate=FALSE)

# 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: EDA 5 symbols, too large

# generate plot with background
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)

SymbLegend(X,Y,el,type="boxplot",qutiles<-c(0,0.05,0.25,0.75,0.95,1),symbtype="EDA",symbmagn=1.2,
leg.position="topright",leg.title="As [mg/kg]",leg.title.cex=1.0,leg.round=2,leg.wid=4,
leg.just="right",cex.scale=0.85,xf=9e3,logscale=TRUE,accentuate=FALSE)

# 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: EDA 5 symbols, dot too large

# generate plot with background
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)

SymbLegend(X,Y,el,type="boxplot",qutiles<-c(0,0.05,0.25,0.75,0.95,1),symbtype="EDA",
symbmagn=c(0.8,0.8,3,0.8,0.8),
leg.position="topright",leg.title="As [mg/kg]",leg.title.cex=1.0,leg.round=2,leg.wid=4,
leg.just="right",cex.scale=0.85,xf=9e3,logscale=TRUE,accentuate=FALSE)

# 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()
# Fig. 5.15.: Map with wrong growing dots
library(StatDA)
data(chorizon)
data(kola.background)
el=chorizon[,"As"]
X=chorizon[,"XCOO"]
Y=chorizon[,"YCOO"]


# true representation of x and y axis of map for plot
xwid=diff(range(X))/12e4
ywid=diff(range(Y))/12e4

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



### NEW MAP:

# generate plot with packground
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)

bubbleFIN(X,Y,el,S=9,s=2,plottitle="",legendtitle="As [mg/kg]", text.cex=0.63,
legtitle.cex=0.70,ndigits=2)

# Percentile legend
text(min(X)+diff(range(X))*5/7,max(Y),"Exponentially",cex=0.70)
text(min(X)+diff(range(X))*5/7,max(Y)-diff(range(Y))/25,"growing dots",cex=0.70)

# scalebar
scalebar(761309,7373050,861309,7363050,shifttext=-0.5,shiftkm=4e4,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:
# take symbols according to quantiles:
qu=c(0,0.1,0.25,0.5,0.75,0.90,0.95,1)
q=quantile(el, qu)

# symbols and size
symb=c(16,16,16,16,16,16,16)
ssize=c(0.3,0.5,0.7,0.9,1.1,1.3,1.7)*0.63

# generate plot with packground
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)

# plot symbols:
for (i in 1:(length(qu)-1)){
points(X[el>=q[i] & el=q[i] & el }
points(X[el>=q[length(qu)]],Y[el>=q[length(qu)]],pch=symb[length(qu)],cex=ssize[length(qu)])

#Legend
legn=round(q,2)
leg=rep(NA,length(q)-1)
leg[1]=paste(" ",format(legn[1],nsmall=2),"-",format(legn[1+1],nsmall=2,width=5,justify="right"))
for (i in 2:(length(q)-1)){
leg[i]=paste(">",format(legn[i],nsmall=2),"-",format(legn[i+1],nsmall=2,
width=5,justify="right"))
}
legend("topright",pch=rev(symb),pt.cex=rev(ssize), legend=rev(leg), title="As [mg/kg]",
cex=0.62)

# Percentile legend
text(min(X)+diff(range(X))*4/7,max(Y),paste(qu*100,collapse=","),cex=0.54)
text(min(X)+diff(range(X))*4/7,max(Y)-diff(range(Y))/25,"Percentiles",cex=0.63)

# scalebar
scalebar(761309,7373050,861309,7363050,shifttext=-0.5,shiftkm=4e4,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()