I am trying to make my graph look as good as possible. I have tried a few things. I would like to make the arrow halfway through the lines. And I always see the colours on graphs from ggplot look nicer too but I don't know where to go with it. Any changes to the below/advice would be great.
x<-c(2,3,3,4,4,5,5)
w<-c(168,108,158,45,114,81,110)
w<-as.data.frame(w)
x<-as.data.frame(x)
wts<-data.frame(x,w)
h <- ggplot(data=wts, aes(x,w, label="w"))
h <- h + geom_point(colour="blue")
h <- h + labs(title="Breaches",x = "Quarter", y= "Number of Breaches")
h<-h + theme_bw()
h
h<-h +
geom_line(data=wts[c(1,2),], colour="green",arrow=arrow())+
geom_line(data=wts[c(3,4),], color="green",arrow=arrow())+
geom_line(data=wts[c(5,6),], color="green",arrow=arrow())+
geom_line(data=wts[c(2,3),], color="red",arrow=arrow())+
geom_line(data=wts[c(4,5),], color="red",arrow=arrow())+
geom_line(data=wts[c(6,7),], color="red",arrow=arrow())
# h<-h+
# geom_point(data=wts[c(8,9,10),], color="red")
h
txt2<- c("60","","","","","","")
txt3<- c("","","113","","","","")
txt4<- c("","","","","","33","")
txt5<- c("","50","","","","","")
txt6<- c("","","","69","","","")
txt7<- c("","","","","","","29")
txt7a<- c("168","108","158","45","114","81","110")
h<-h+ geom_text(aes(label=txt2),position = position_nudge(x=0.5,y = -30))
h<-h+ geom_text(aes(label=txt3),position = position_nudge(x=0.4,y = -30))
h<-h+ geom_text(aes(label=txt4),position = position_nudge(x=-0.45,y = 20))
h<-h+ geom_text(aes(label=txt5),position = position_nudge(x=0.1,y = 15))
h<-h+ geom_text(aes(label=txt6),position = position_nudge(x=0.1,y = 30))
h<-h+ geom_text(aes(label=txt7),position = position_nudge(x=0.1,y = -10))
h<-h+ geom_text(aes(label=txt7),position = position_nudge(x=0.1,y = -10))
h<-h+ geom_text(aes(label=txt7a),position = position_nudge(x=0.1,y = 0))
h<-h + ylim(25,170)
h<-h+
scale_x_continuous(breaks=c(2,3,4,5),
labels=c("Q218","Q318", "Q418", "Q119"))
h
You can follow the @Axeman suggestion: my management is quite ugly, but I've tried to make it as general as possible, and you can tweak it as you prefere.
Now you can try to add the labels, I've used the nice
ggrepel
package, to repel them from the points