Reputation: 175
I'm wanting to add vertical dotted/dashed on top of my time series graph at even intervals.
Would I put an extra command in the abline arguments or is there another way?
Upvotes: 2
Views: 1679
Reputation: 1082
You can supply vector arguments for v
parameter in abline()
to plot multiple lines. lty
parameter lets you specify line type and also can be a vector.
Quick example:
x=1:16
y=2*x+rnorm(16)
plot(x,y,type='b')
abline(v=.3+1:16,lty=rep(c(3,4),times = 8))
Upvotes: 4
Reputation: 56219
Use grid:
nx, ny - number of cells of the grid in x and y direction. When NULL, as per default, the grid aligns with the tick marks on the corresponding default axis (i.e., tickmarks as computed by axTicks). When NA, no grid lines are drawn in the corresponding direction.
Example:
plot(1:5)
grid(nx = NULL, ny = NA)
Upvotes: 4