require(ggplot2)
require(knitr)
source("trapezium.R")
dirdat <- ".."
We use the simplified table sent by Gabor
options("width"=140)
vmetrics <- read.csv(file.path(dirdat,"test.csv"),stringsAsFactors = FALSE)
#head(vmetrics)
names(vmetrics) <- c("Edifice","Type", "Ccr", "Dcrmax", "Scrmean",
"Scrmedian","Wco", "Hco","Smean","Smedian",
"Hco/Wco","Ccr/Wco","Dcr/Hco", "Crmin/Crmax",
"Elong", "IsoCirc")
summary(vmetrics)
Edifice Type Ccr Dcrmax Scrmean Scrmedian Wco Hco
Length:26 Length:26 Min. : 230.0 Min. : 7.00 Min. : 5.30 Min. : 5.10 Min. : 310.0 Min. : 5.50
Class :character Class :character 1st Qu.: 368.5 1st Qu.: 24.25 1st Qu.:20.05 1st Qu.:19.50 1st Qu.: 625.4 1st Qu.:21.12
Mode :character Mode :character Median : 496.0 Median : 58.50 Median :22.60 Median :23.30 Median : 975.2 Median :49.75
Mean : 605.0 Mean : 80.15 Mean :21.45 Mean :21.90 Mean :1052.7 Mean :43.69
3rd Qu.: 758.0 3rd Qu.: 96.75 3rd Qu.:25.15 3rd Qu.:25.25 3rd Qu.:1264.5 3rd Qu.:62.88
Max. :1379.0 Max. :298.00 Max. :31.30 Max. :34.00 Max. :2323.5 Max. :95.00
NA's :3 NA's :3
Smean Smedian Hco/Wco Ccr/Wco Dcr/Hco Crmin/Crmax Elong IsoCirc
Min. : 2.70 Min. : 2.30 Min. :0.01000 Min. :0.4000 Min. :0.470 Min. :0.6200 Min. :0.5600 Min. :0.7900
1st Qu.: 8.05 1st Qu.: 7.15 1st Qu.:0.02000 1st Qu.:0.5200 1st Qu.:1.095 1st Qu.:0.8000 1st Qu.:0.8200 1st Qu.:0.8925
Median :15.85 Median :15.80 Median :0.04500 Median :0.5900 Median :1.460 Median :0.9000 Median :0.9200 Median :0.9400
Mean :15.27 Mean :14.95 Mean :0.04885 Mean :0.5842 Mean :1.793 Mean :0.8712 Mean :0.8823 Mean :0.9265
3rd Qu.:19.23 3rd Qu.:19.30 3rd Qu.:0.06000 3rd Qu.:0.6550 3rd Qu.:1.910 3rd Qu.:0.9500 3rd Qu.:0.9875 3rd Qu.:0.9700
Max. :34.20 Max. :34.20 Max. :0.16000 Max. :0.7400 Max. :5.680 Max. :1.0700 Max. :1.1000 Max. :0.9800
#head(vmetrics,3)
I thought it would be interesting seeing a simplified shape of the edifices from the metrics Hco (cone height), Ccr (mean crater diameter) and Wco (cone width). I hacked trapezium.R from original matlab code. This function returns the vertices of a trapezium given height and both diameters, e.g.
plot(trapezium(h=vmetrics$Hco[1], a=vmetrics$Ccr[1], b=vmetrics$Wco[1]),
xlab="",ylab="",main=c(vmetrics$Edifice[1],vmetrics$Type[1]))
lines(trapezium(h=vmetrics$Hco[1], a=vmetrics$Ccr[1], b=vmetrics$Wco[1]))
I use this function to calculate the vertices of all trapezii and then display with ggplot:
a <-NULL
for(i in (1:nrow(vmetrics))) {
a <- rbind(a,trapezium(h=vmetrics$Hco[i], a=vmetrics$Ccr[i], b=vmetrics$Wco[i]))
}
a <- data.frame(a)
b <- data.frame(Edifice=rep(vmetrics$Edifice,rep(5,nrow(vmetrics))),
Type=rep(vmetrics$Type,rep(5,nrow(vmetrics))),
x=a[,1], y=a[,2])
b <- rbind(b[b$Type=="Tuff Cone",],b[b$Type=="Tuff Ring",])
b$Edifice <- factor(b$Edifice, levels=unique(b$Edifice))
g1 <- ggplot(data=b) +
geom_path(aes(x=x,y=y,group=Edifice,col=Type),size=1) +
xlab("Diameter (Wco and Ccr)") + ylab("Cone Height") +
theme(axis.text.x=element_text(angle=45,hjust=1)) +
facet_wrap(~Edifice) +
ggtitle("Simplified view of volcanic edifices (I)")
print(g1)
Figure 1. Simplified view of volcanic edifices as trapezii. Scale is kept constant so differences in size can be appreciated.
g2 <- ggplot(data=b) +
geom_path(aes(x=x,y=y,group=Edifice,col=Type),size=1) +
xlab("Diameter (Wco and Ccr)") + ylab("Cone Height") +
theme(axis.text.x=element_text(angle=45,hjust=1)) +
facet_wrap(~Edifice, scales="free_y") +
ggtitle("Simplified view of volcanic edifices (II)")
print(g2)
Figure 2. Simplified view of volcanic edifices as trapezii. Only x scale is kept constant hence emphasizing differences in shape