Skip to content

Instantly share code, notes, and snippets.

@so-c
Created December 17, 2013 15:43
Show Gist options
  • Save so-c/8006959 to your computer and use it in GitHub Desktop.
Save so-c/8006959 to your computer and use it in GitHub Desktop.
2013年に読んだ本のバーチャートをggplot2で書く。
library("ggplot2")
entries <- data.frame(label=factor(c("小説", "読書", "漫画", "新書"),
levels=c("小説", "読書", "漫画", "新書")),
num=c(64, 48, 44, 2))
g <- ggplot(entries, aes(x=label, y=num, fill=label))
p <- g + geom_bar()
p <- p + xlab("ラベル") + ylab("投稿数") + ggtitle("2013年に読んだ本") + theme(legend.position = "none")
plot(p)
ggsave(file="books2013.png", plot=p, width=8.0, height=6.4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment