Usage and Capacity of TEPCO electric power in ggplot2


https://twitter.com/ogiek_y/status/50358200544919552というツイートを見かけたので作った。
更新はしませんが、コードは自由に使ってください。

library(ggplot2)
library(rjson)

d <-  do.call("rbind",
  lapply(fromJSON(paste(readLines("http://tepco-usage-api.appspot.com/2011/3.json", warn=F), collapse="")),
  data.frame))

d <- transform(d, 
  Rate = usage/capacity,
  Ptime = as.POSIXct(entryfor)+9*60*60
  )
  
ggplot(d, aes(x=Ptime)) + 
  geom_line(aes(y=capacity), colour="red", size=3) +
  geom_area(aes(y=usage), alpha=0.5, fill="red") +
  coord_cartesian(ylim=c(0, 5000), wise=TRUE) +
  labs(x="日時", y="供給・使用電力量(万KW)") +
  theme_grey(base_family="sans")

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s