setwd("C:/Users/s-das/Syncplicity Folders/155660--- Urban Freeway Fatality/NEW2")
tmc <- read.csv("TMC2.csv")
library(ggplot2)
library(ggrepel)
## Warning: package 'ggrepel' was built under R version 3.2.5
cbPalette <- c("#046C9A", "#46ACC8", "#E1AF00", "#DC863B")
ggplot(tmc) + geom_segment(aes(color=Direction, x=miles,
xend=miles1, y=Direction, yend=Direction), size=1.5,
arrow=arrow(length=unit(0.4,"cm"))) +theme_bw()+
geom_point(aes(x=miles1,y=Direction, color=Direction) ,size=2)+
geom_point(aes(x=2,y=1) ,size=7, color="green")+
geom_point(aes(x=2,y=3) ,size=7, color="grey")+
geom_label_repel(aes(x=miles1,y= Direction, label=speed1, color = Direction),
fontface = 'bold', force=60,
box.padding = unit(0.25, "lines"),
point.padding = unit(0.5, "lines"))+
scale_colour_manual(values=cbPalette)+
geom_vline(xintercept = 2, color="red", linetype = "longdash", size=1.5)+
annotate("text", label = "Crash time: 08:11:45 AM", x = 2.05, y=3.1, size = 5, colour = "red", angle=90)+
geom_segment(aes(x=1.6,y= 0.8, xend = 2, yend = 1),
colour='red', size=0.5,arrow = arrow(length = unit(0.5, "cm")))+
annotate("text", x=1.5,y= 0.75, label = "Crash on Northbound",
size=4, colour='red') +
geom_segment(aes(x=1.6,y= 2.8, xend = 2, yend = 3),
colour='red', size=0.5,arrow = arrow(length = unit(0.5, "cm")))+
annotate("text", x=1.5,y= 2.75, label = "Crash on Opposite Bound",
size=4, colour='red') +labs(x="Distance (in miles)")
by Subasish Das