X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2Fplot.R;h=2488d81548202fa9af8e8e3e2a1f23f006914694;hb=4f3fdbb8e2ac4bd57a4e27539a58ef0e7ec2304c;hp=ad0ed4ea7e5ac0999d270a10c1dd8ea61d0b7753;hpb=cf3bb00128ac8cb930996455faf7c99a3fc102fb;p=talweg.git diff --git a/pkg/R/plot.R b/pkg/R/plot.R index ad0ed4e..2488d81 100644 --- a/pkg/R/plot.R +++ b/pkg/R/plot.R @@ -11,13 +11,7 @@ plotCurves <- function(data, indices=seq_len(data$getSize())) series = data$getSeries(indices) yrange = quantile(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) - for (i in seq_along(indices)) - { - plot(series[,i], type="l", ylim=yrange, - xlab=ifelse(i==1,"Time (hours)",""), ylab=ifelse(i==1,"PM10","")) - if (i < length(indices)) - par(new=TRUE) - } + matplot(series, type="l", ylim=yrange, xlab="Time (hours)", ylab="PM10") } #' Plot error @@ -83,7 +77,7 @@ plotError <- function(err, cols=seq_along(err)) plotPredReal <- function(data, pred, index) { prediction = pred$getForecast(index) - measure = data$getSerie( pred$getIndexInData(index) )[length(prediction)] + measure = data$getSerie( pred$getIndexInData(index) )[1:length(prediction)] 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") @@ -172,8 +166,8 @@ computeFilaments <- function(data, pred, index, predict_from, limit=60, plot=TRU ref_serie = c( data$getCenteredSerie( pred$getIndexInData(index)-1 ), data$getCenteredSerie( pred$getIndexInData(index) ) ) centered_series = rbind( - data$getCenteredSeries( pred$getParams(index)$indices ), - data$getCenteredSeries( pred$getParams(index)$indices+1 ) ) + data$getCenteredSeries( pred$getParams(index)$indices-1 ), + data$getCenteredSeries( pred$getParams(index)$indices ) ) 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) @@ -208,8 +202,9 @@ plotFilamentsBox = function(data, fil, predict_from) stop("Functional boxplot requires the rainbow package") series_matrix = rbind( - data$getSeries(fil$neighb_indices), data$getSeries(fil$neighb_indices+1) ) + data$getSeries(fil$neighb_indices-1), data$getSeries(fil$neighb_indices) ) series_fds = rainbow::fds(seq_len(nrow(series_matrix)), series_matrix) + par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5) rainbow::fboxplot(series_fds, "functional", "hdr", xlab="Time (hours)", ylab="PM10", plotlegend=FALSE, lwd=2) @@ -234,8 +229,8 @@ plotFilamentsBox = function(data, fil, predict_from) #' @export plotRelVar = function(data, fil, predict_from) { - ref_var = c( apply(data$getSeries(fil$neighb_indices),1,sd), - apply(data$getSeries(fil$neighb_indices+1),1,sd) ) + 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),