Personally, I feel it would not be hard to make a quick plot, but it worth putting some time to make this small task look nicer. Therefore, I decided to use ggplot2 and make the plot in R.
Hope someone who also wants to make similar plots like I did can eventually find my code and procedure useful. If anyone has other interesting ideas to make the plots nicer or more informative, please leave your comment :)
library(ggplot2) #import ggplot2 library
dat <- read.csv("community_crime.csv",header=T)
dat$community = factor(dat$community,
labels=c("Beverly Hill","Washington Heights","Mount Greenwood","Morgan Park"))
X11(width = 18, height = 12)
ggplot(dat, aes(x=year, y=any_1000, color=community)) +
geom_point(shape=19,size=I(8),alpha = 0.3) +
scale_colour_hue(l=50) + # Use a slightly darker palette than normal
geom_smooth(method=lm, # Add linear regression lines
se=FALSE, # Don't add shaded confidence region
fullrange=T, size=1.4)+ # Extend regression lines
ylab("all crime count per 1000 population")+
xlab("Year")+
opts(title = expression("All Crime Count per 1000 population"))
No comments:
Post a Comment