Skip to content

Instantly share code, notes, and snippets.

@corynissen
Last active December 16, 2015 08:29
Show Gist options
  • Save corynissen/5406010 to your computer and use it in GitHub Desktop.
Save corynissen/5406010 to your computer and use it in GitHub Desktop.
dodged vs faceted blog post
# faceted
ggplot(df, aes(x=factor(game), y=score)) +
geom_bar(stat="identity",aes(fill=factor(game))) + facet_grid(.~name) +
coord_cartesian(ylim=c(50, 150)) + scale_y_continuous(breaks=a[a%%10==0]) +
scale_fill_discrete(name="Game") + xlab("") + ylab("Score")
ggsave("faceted_bowling.jpg")
# dodged
ggplot(df, aes(x=factor(name), y=score)) +
geom_bar(position="dodge", stat="identity",aes(fill=factor(game))) +
coord_cartesian(ylim=c(50, 150)) + scale_y_continuous(breaks=a[a%%10==0]) +
xlab("") + ylab("Score") + scale_fill_discrete(name="Game") +
opts(axis.text.x = theme_text(size=14))
ggsave("dodged_bowling.jpg")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment