joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
219 stars 70 forks source link

addPolygon doesn't render when observation.based = TRUE #403

Closed joshuaulrich closed 11 months ago

joshuaulrich commented 11 months ago
library(xts)
data(sample_matrix)
rets <- diff(log(as.xts(sample_matrix)[,"Close"]))[-1]

nr <- nrow(rets)
shade <- xts(cbind(u = rep(max(rets), nr), l = rep(min(rets), nr)), index(rets))

# shading renders
plot(rets)
addPolygon(shade["2007-02"], col = "grey", on = -1)

# shading does not render
plot(rets, observation.based = TRUE)
addPolygon(shade["2007-02"], col = "grey", on = -1)