I have several graphs of time series data, and I need a horizontal line on each graph, but with different horizontal values (for example, 1st graph: h=50 , 2nd graph: h=48 ...).
I tried abline(h=50... and I get a horizontal line in each graph. I tried abline(h=c(50,48... and I get multiline horizontal lines on each graph.
I cannot figure out how to get the index plot.zoo in order to build h=50 in the 1st plot, h=48 in the second plot, etc.
library(xts) data(sample_matrix) x <- as.xts(sample_matrix) # plot with single line my.panel <- function(x, ...) { lines(x, ...) abline(h=50, col = "red", lty="solid", lwd=1.5 ) } plot.zoo(x, main="title", plot.type="multiple", type="o", lwd=1.5, col="blue", panel=my.panel) # plot multiple lines in all plots my.panel <- function(x, ...) { lines(x, ...) abline(h=c(50,50,48,50), col = "red", lty="solid", lwd=1.5 )} plot.zoo(x, main="title", plot.type="multiple", type="o", lwd=1.5, col="blue", panel=my.panel)
r plot zoo
daniele
source share