data(geoMite)
attach(geoMite)
## Color definitions:
col <- list()
col[["substrate"]] <- c(Sphagn1 = "#00ff00", Sphagn2 = "#fffb00",
Sphagn3 = "#774b00", Sphagn4 = "#ff8400",
Litter = "#ee00ff", Barepeat = "#ff0004")
col[["water"]] <- c(Water = "#008cff", Flooded = "#ffffff00",
core = "#000000ff")
col[["shrub"]] <- c(None = "#dfdfdf", Few = "#a7a7a7", Many = "#5c5c5c")
col[["topo"]] <- c(Blanket = "#74cd00", Hummock = "#bc9d00")
## Graphical paramters:
p <- par(no.readonly = TRUE)
par(mar=c(0,0,1,0), mfrow=c(1L,4L))
## Substrate:
plot(st_geometry(substrate), col=col[["substrate"]][substrate$Type],
main="Substrate")
plot(st_geometry(water[1L,]), col=col[["water"]][water[1L,]$Type], add=TRUE)
plot(st_geometry(water[-1L,]), col=col[["water"]][water[-1L,]$Type], lty=3L,
add=TRUE)
plot(st_geometry(core), pch = 21L, bg = "black", add=TRUE)
## Shrubs:
plot(st_geometry(shrub), col = col[["shrub"]][shrub$Type], main="Shrubs")
plot(st_geometry(water[1L,]), col=col[["water"]][water[1L,]$Type], add=TRUE)
plot(st_geometry(water[-1L,]), col=col[["water"]][water[-1L,]$Type], lty=3L,
add=TRUE)
plot(st_geometry(core), pch = 21L, bg = "black", add=TRUE)
## Topograghy:
plot(st_geometry(topo), col = col[["topo"]][topo$Type], main="Topography")
plot(st_geometry(water[1L,]), col=col[["water"]][water[1L,]$Type], add=TRUE)
plot(st_geometry(water[-1L,]), col=col[["water"]][water[-1L,]$Type], lty=3L,
add=TRUE)
plot(st_geometry(core), pch = 21L, bg = "black", add=TRUE)
## Legends:
plot(NA, xlim=c(0,1), ylim=c(0,1), axes = FALSE)
legend(x=0, y=0.9, pch=22L, pt.cex = 2.5, pt.bg=col[["substrate"]],
box.lwd = 0, legend=names(col[["substrate"]]), title="Substrate")
legend(x=-0.025, y=0.6, pch=c(22L,NA,21L), pt.cex = c(2.5,NA,1),
pt.bg=col[["water"]], box.lwd = 0, lty = c(0L,3L,NA),
legend=c("Open water","Flooded area","Peat core"))
legend(x=0, y=0.4, pch=22L, pt.cex = 2.5, pt.bg=col[["shrub"]], box.lwd = 0,
legend=names(col[["shrub"]]), title="Shrubs")
legend(x=0, y=0.2, pch=22L, pt.cex = 2.5, pt.bg=col[["topo"]], box.lwd = 0,
legend=names(col[["topo"]]), title="Topography")
### Display the species counts
## Get the species names:
unlist(
lapply(
strsplit(colnames(core),".",fixed=TRUE),
function(x) if(x[1L] == "Species") x[2L] else NULL
)
) -> spnms
## See the maximum counts for all the species
apply(st_drop_geometry(core[,paste("Species",spnms,sep=".")]),2L,max)
## Species selection to display:
sel <- c("Brachysp","Hoplcfpa","Oppinova","Limncfci","Limncfru")
## Range of counts to display:
rng <- log1p(c(0,1000))
colmap <- grey(seq(1,0,length.out=256L))
## Update the graphical parameters for this example
par(mar=c(0,0,2,0), mfrow=c(1L,length(sel) + 1L))
## Display each species in the selection over the substrate map
for(sp in sel) {
plot(st_geometry(substrate), col=col[["substrate"]][substrate$Type],
main=sp)
plot(st_geometry(core), pch=21L, add = TRUE, cex=1.5,
bg=colmap[1 + 255*log1p(core[[paste("Species",sp,sep=".")]])/rng[2L]])
}
## Display the colour chart for the species counts:
par(mar=c(2,7,3,1))
image(z=matrix(seq(0,log1p(1000),length.out=256L),1L,256L), col=colmap,
xaxt="n", yaxt="n", y=seq(0,log1p(1000),length.out=256L), xlab="",
cex.lab = 1.5,
ylab=expression(paste("Counts by species (",ind~core^{-1},")")))
axis(2L, at=log1p(c(0,1,3,10,30,100,300,1000)), cex.axis = 1.5,
label=c(0,1,3,10,30,100,300,1000))
## Restore graphical parameters:
par(p)
Run the code above in your browser using DataLab