Skip to content

Instantly share code, notes, and snippets.

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