Murders in India – 2016

Following chart shows trend in murder cases in India by state. The advantage of using a geo facet chart is that it give a geographic location of the state. The black horizontal line in the plot corresponds to the average number of murder cases in India in 2016. This gives us a quick overview of the states where the murder cases are higher than national average and the states below the national average.

murder_geofacet

 

It should be notes that the latest data available is 2016 so there is a lag of about 2 years. I have extracted the data for this plot from NCRB.  But if you like to reproduce this plot without going through the manual labor you can download the data here.

Following is the R code used to generate the plot. Part of this code is inspired by Len blog.

library(geofacet)
library(ggplot2)
library(reshape2)
###################################################
Import and process data
###################################################
setwd("<path to your directory with the data>")
mrder = read.csv("murder.csv", stringsAsFactors = FALSE)
colnames(mrder) <- c("state","2010","2011","2012","2013","2014","2015","2016")
mrder= melt(mrder, id.vars = "state", variable.name = "year")
################################################
Geo Facet Plot for India
################################################
ggplot(mrder, aes(year, value)) +
 facet_geo(~ state, grid ="india_grid2") +
 scale_x_discrete(labels=c("'10","12","14","16"), breaks=c(2010,2012,2014,2016))+
 geom_col(fill = "#fa9fb5")+
 geom_hline(yintercept = 1029) +
 theme_bw()+
 theme(axis.text.x=element_text(size=8),legend.key.width=unit(2,"cm"),
 axis.text.y=element_text(size=8),
 legend.position="top",
 plot.caption=element_text(hjust=0),
 plot.subtitle=element_text(face="italic",hjust=0.5,size=10),
 plot.title=element_text(size=18,face="bold",hjust=0.5))+
 labs(x="Year",y="Murder Cases",title="Murder cases in India by states",subtitle="National Crime Statistics of India",caption="Source: http://ncrb.gov.in/")

Please feel free to leave a comment if you come across any issue or just wanna say Hi !!!

Leave a Reply

WordPress.com.

Up ↑

%d bloggers like this: