#!R -f
(function(lp) {
np <- lp[!(lp %in% installed.packages()[,"Package"])]
if(length(np)) install.packages(np,repos=c("https://cran.rstudio.com/"))
x <- lapply(lp,function(x){library(x,character.only=TRUE)})
})(c("ggplot2", "ggthemes", "gtable", "reshape2"))
theme <- theme_few(base_size = 24) +
theme(axis.title.y=element_text(vjust=0.9),
axis.title.x=element_text(vjust=-0.1),
axis.ticks.x=element_blank(),
text=element_text(family="serif"),
legend.position = "none")
dd <- read.table("results.csv", sep="\t", header=F)
names(dd) <- c("sys", "dataset", "nrows", "loadtime", "querytime", "readtime")
ddm <- melt(dd[c(1,2,4,5,6)], id.vars=c("sys","dataset"))
ddm$sys <- factor(ddm$sys, c("MonetDBLite", "MonetDB.R", "SQLite"))
print(ddm)
xlf <- function(value) ifelse(value == 0, "DNF", ifelse(value < 10,
paste0(round(value, 1), "s"), paste0(round(value), "s")))
plt <- function(ddp, fname, xmax, title) {
pdf(fname, width=10, height=5)
p <- ggplot(ddp,aes(x=dataset, y=value, fill=sys)) +
geom_bar(stat="identity", position = "dodge", width=.7) +
geom_text(aes(label = xlf(value), family="serif"), size = 5, vjust=-.4,
position = position_dodge(width=.7)) +
scale_x_discrete(labels=xlabel) +
scale_y_continuous(limits=c(0, xmax)) +
scale_fill_manual(values=c( "#1f78b4", "#a6cee3", "#b2df8a")) +
xlab("# Tuples") + ylab("Time (s)") + theme + ggtitle(title)
# haaaack (secondary x axis patched in using gtable)
axis <- ggplot(ddp,aes(x=dataset, y=value, fill=sys)) +
geom_text(aes(label=sys, y=0, family="serif"), angle=90, size = 5, hjust = 0.55,
position = position_dodge(width=.7))
annotation <- gtable_filter(ggplotGrob(axis), "panel", trim=TRUE)
annotation[["grobs"]][[1]][["children"]][c(1,3)] <- NULL
g <- ggplotGrob(p)
g <- gtable_add_rows(g, unit(6, "line"), pos=3)
g <- gtable_add_grob(g, annotation, t=4, b=4, l=4, r=4)
grid.draw(g)
dev.off()
}
xlabel <- c("1"="60K", "2"="600K", "3"="6M", "4"="60M", "f"="128M")
plt(ddm[ddm$variable=='loadtime',], "load.pdf", 10000, "Loading from CSV files")
plt(ddm[ddm$variable=='querytime',], "query.pdf", 70, "Run HMDA analysis")
xlabel <- c("1"="10K", "2"="100K", "3"="1M", "4"="10M", "f"="14M")
plt(ddm[ddm$variable=='readtime',], "read.pdf", 1500, "Convert table to data.frame")