+
+ # "Magic": http://stackoverflow.com/questions/13842560/get-xlim-from-a-plot-in-r
+ usr <- par("usr")
+ yr <- (usr[4] - usr[3]) / 27
+ par(new=TRUE)
+ plot(c(data$getSerie(fil$index-1),data$getSerie(fil$index)), type="l", lwd=2, lty=2,
+ ylim=c(usr[3] + yr, usr[4] - yr), xlab="", ylab="")
+ abline(v=24+predict_from-0.5, lty=2, col=colors()[56])
+}
+
+#' Plot relative conditional variability / absolute variability
+#'
+#' Draw the relative conditional variability / absolute variability based on filaments
+#' obtained by \code{computeFilaments()}.
+#'
+#' @inheritParams computeError
+#' @inheritParams plotFilamentsBox
+#'
+#' @export
+plotRelVar = function(data, fil, predict_from)
+{
+ ref_var = c( apply(data$getSeries(fil$neighb_indices-1),1,sd),
+ apply(data$getSeries(fil$neighb_indices),1,sd) )
+ tdays = .getNoNA2(data, 2, fil$index)
+ global_var = c(
+ apply(data$getSeries(tdays-1),1,sd),
+ apply(data$getSeries(tdays),1,sd) )
+
+ yrange = range(ref_var, global_var)
+ par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5)
+ plot(ref_var, type="l", col=1, lwd=3, ylim=yrange,
+ xlab="Time (hours)", ylab="Standard deviation")
+ par(new=TRUE)
+ plot(global_var, type="l", col=2, lwd=3, ylim=yrange, xlab="", ylab="")
+ abline(v=24+predict_from-0.5, lty=2, col=colors()[56])