add realtime option, slightly refactor data acquisition
[talweg.git] / pkg / R / plot.R
index 52b077b..5ea4843 100644 (file)
@@ -28,8 +28,8 @@ plotCurves <- function(data, indices=seq_len(data$getSize()))
 #' @param cols Colors for each error (default: 1,2,3,...)
 #'
 #' @seealso \code{\link{plotCurves}}, \code{\link{plotPredReal}},
-#'   \code{\link{plotSimils}}, \code{\link{plotFbox}},
-#'   \code{\link{computeFilaments}, }\code{\link{plotFilamentsBox}}, \code{\link{plotRelVar}}
+#'   \code{\link{plotSimils}}, \code{\link{plotFbox}}, \code{\link{computeFilaments}},
+#'   \code{\link{plotFilamentsBox}}, \code{\link{plotRelVar}}
 #'
 #' @export
 plotError <- function(err, cols=seq_along(err))
@@ -83,9 +83,9 @@ plotError <- function(err, cols=seq_along(err))
 #' @export
 plotPredReal <- function(data, pred, index)
 {
-       horizon = length(pred$getSerie(1))
+       horizon = length(pred$getForecast(1))
        measure = data$getSerie( pred$getIndexInData(index)+1 )[1:horizon]
-       prediction = pred$getSerie(index)
+       prediction = pred$getForecast(index)
        yrange = range(measure, prediction)
        par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5, lwd=3)
        plot(measure, type="l", ylim=yrange, xlab="Time (hours)", ylab="PM10")
@@ -175,7 +175,8 @@ computeFilaments <- function(data, pred, index, limit=60, plot=TRUE)
                centered_series = rbind(
                        data$getCenteredSeries( pred$getParams(index)$indices ),
                        data$getCenteredSeries( pred$getParams(index)$indices+1 ) )
-               yrange = range( ref_serie, quantile(centered_series, probs=c(0.025,0.975), na.rm=TRUE) )
+               yrange = range( ref_serie,
+                       quantile(centered_series, probs=c(0.025,0.975), na.rm=TRUE) )
                par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5, lwd=2)
                for (i in nn:1)
                {
@@ -214,7 +215,7 @@ plotFilamentsBox = function(data, fil)
        rainbow::fboxplot(series_fds, "functional", "hdr", xlab="Time (hours)", ylab="PM10",
                plotlegend=FALSE, lwd=2)
 
-       # "Magic" found at http://stackoverflow.com/questions/13842560/get-xlim-from-a-plot-in-r
+       # "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)
@@ -237,7 +238,9 @@ plotRelVar = function(data, fil)
        ref_var = c( apply(data$getSeries(fil$neighb_indices),1,sd),
                apply(data$getSeries(fil$neighb_indices+1),1,sd) )
        fdays = getNoNA2(data, 1, fil$index-1)
-       global_var = c( apply(data$getSeries(fdays),1,sd), apply(data$getSeries(fdays+1),1,sd) )
+       global_var = c(
+               apply(data$getSeries(fdays),1,sd),
+               apply(data$getSeries(fdays+1),1,sd) )
 
        yrange = range(ref_var, global_var)
        par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5)