I am plotting some values of autocorrelation in a R:
plot(y=lag[2:N],x=1:(N-1), xlab="lag",ylab="Autocorrelation",ylim=c(-1,1), pch=16,col="red")
abline(h=0, col="black")
abline(h=up, col="blue")
abline(h=low, col="blue")
This is my code and this is what I got in R
However, I want something like the image below, where I connect the points with a red line to the horizontal line at 0.
Any idea how to do it?
You can add vertical lines with type = "h"
, and then add the points separately
plot(y=lag[2:N],x=1:(N-1), xlab="lag",ylab="Autocorrelation",ylim=c(-1,1), col="black", type = "h")
points(y=lag[2:N],x=1:(N-1), xlab="lag", ylim=c(-1,1), pch=16,col="red", type = "p")