0

I have searched very hard for a solution to this question, but I haven't been successful. I have a zoo plot with your standard time series X axis and simply want to highlight regions of the chart when the value of the series is less than a certain threshold. Specifically, I want to highlight when the p-value of the intercept is significant (and the intercept is plotted). This will occur at various intervals across the time series, rather than simply some range x <= y.

I have tried help (xblocks) example (xblocks) and I haven't been able to get the highlighted region to show for the dates to which I know they should apply.

Shafizadeh
  • 9,960
  • 12
  • 52
  • 89
user2662565
  • 509
  • 2
  • 9
  • 22
  • 1
    Questions should contain self-contained minimal code and data to reproduce your problem (i.e. so anyone else can copy it from your question and paste it into a running R session and see what you see). These links discuss this further: http://stackoverflow.com/help/how-to-ask http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – G. Grothendieck Sep 28 '15 at 22:14

1 Answers1

1

Does this solves your problem?

rgb <- hcl(c(0, 0, 260), c = c(100, 0, 100), l = c(50, 90, 50), alpha = 0.3)
set.seed(1234)
x.Date <- as.Date("2015-02-01") + c(1,3,6,7,9,10,12,14,18,20) - 1
y <- zoo(rnorm(length(x.Date)), x.Date)
pval<-zoo(runif(length(x.Date),0,.2), x.Date)
plot(y,col=4)
xblocks(pval<=0.05,col = rgb[1])

enter image description here

Robert
  • 5,038
  • 1
  • 25
  • 43