X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=R%2Fplot.R;h=b720e9a16fe588f492cb6a77af54516115b94bda;hb=e5aa669afc0b71278d1a864fb0d4e2aff8032ef1;hp=f551ef4263697dd1514130edbc79e516c9bf8c18;hpb=31f7d913d4a99d0a4db9bcfe40e31cebf90b22e6;p=talweg.git diff --git a/R/plot.R b/R/plot.R index f551ef4..b720e9a 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1,3 +1,29 @@ +#' @title plot curves +#' +#' @description Plot a range of curves in data +#' +#' @param data Object of class Data +#' @param indices Range of indices (integers or dates) +#' +#' @export +plotCurves <- function(data, indices) +{ + yrange = range( sapply( indices, function(i) { + serie = c(data$getCenteredSerie(i)) + if (!all(is.na(serie))) + range(serie, na.rm=TRUE) + c() + }) ) + par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5) + for (i in seq_along(indices)) + { + plot(data$getSerie(indices[i]), type="l", ylim=yrange, + xlab=ifelse(i==1,"Temps (en heures)",""), ylab=ifelse(i==1,"PM10","")) + if (ii < length(indices)) + par(new=TRUE) + } +} + #' @title plot measured / predicted #' #' @description Plot measured curve (in black) and predicted curve (in red) @@ -45,8 +71,8 @@ plotFilaments <- function(data, index, limit=60) index = i - first_day + 1 serie = c(data$getCenteredSerie(index), data$getCenteredSerie(index+1)) if (!all(is.na(serie))) - return ( range(serie, na.rm=TRUE) ) - return (0) + return (range(serie, na.rm=TRUE)) + c() }) ) grays = gray.colors(20, 0.1, 0.9) #TODO: 20 == magic number colors = c(