bubble chart by using ggplot2
[This article was first published on YGC » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The visualization represented by Hans Rosling’s TED talk was very impressive. FlowingData provides a tutorial on making bubble chart in R. I prefer ggplot2 for graphics.
crime <- read.csv("http://datasets.flowingdata.com/crimeRatesByState2008.csv", header=TRUE, sep="\t") p <- ggplot(crime, aes(murder,burglary,size=population, label=state)) p <- p+geom_point(colour="red") +scale_area(to=c(1,20))+geom_text(size=3) p + xlab("Murders per 1,000 population") + ylab("Burglaries per 1,000")
Here is what it looks like.
Related Posts
To leave a comment for the author, please follow the link and comment on their blog: YGC » R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.