today I encountered unexpected behavior of plotly when using it from R. I want to plot the uncertainty region around a time series forecast using geom_ribbon. This is why my data has two columsn - one for the upper, one for the lower end of the region - which I pad with NAs until the forecast horizon starts. In regular ggplots the ribbon is thus invisible as long as upper and lower point is NA, but not so in plotly. A reproducible example below:
y <- rnorm(144, 0, 2) y_comp <- data.frame(mean = y, x = 1:144, upper = c(rep(NA, (130)), y[131:144]+3), lower = c(rep(NA, (130)), y[131:144]-3) ) p <- ggplot(y_comp, aes(x = x, y = mean, ymin = lower, ymax = upper)) + geom_line() + geom_ribbon(alpha = .25) library(plotly) ggplotly(p)
Is this expected behavior, or a bug?