yutakashino — Jun 16, 2012, 7:02 PM
#最初の設定
setwd('~/sandbox/nhk/dsmining')
f1 <- file('allAprilMay.out', open='r', encoding='utf-8')
f2 <- file('aprilmayaudrate.out', open='r', encoding='utf-8')
fd1 <- read.csv(file=f1, header=TRUE, stringsAsFactors=FALSE)
fd2 <- read.csv(file=f2, header=TRUE, stringsAsFactors=FALSE)
df <- merge(fd1, fd2, by=c("datetime", "date", "time"))
#プロットするぜ
library(ggplot2)
library(scales)
#quartzFonts(HiraMaru=quartzFont(rep("HiraMaruProN-W4", 4)))
df <- transform(df, stTime = as.POSIXct(time, format="%H:%M:%S"))
p <- ggplot(df, aes(x=stTime))
p <- p + geom_bar(aes(y = num, colour=num) ,stat='identity')
p <- p + geom_path(aes(y = df$rate*20+500), colour = "#3B4FB8", size = 0.3)
p <- p + facet_wrap(~date, ncol=7)
p <- p + scale_x_datetime(breaks = date_breaks("6 hours"),labels = date_format("%H"))
p <- p + ylim(0, 3000)
#p <- p + theme_bw(base_family="HiraMaru", base_size=9) + opts(
p <- p + theme_bw() + opts( axis.text.x = theme_text(size = 5),
axis.text.y = theme_text(size = 5),
strip.background = theme_blank())
#ggsave(p, file="allrate.png", width=10, height=7)
p