X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=R%2Fplot.R;h=9a0dbcd90147854d67bb33cad37c3aa30c6d55ce;hp=f551ef4263697dd1514130edbc79e516c9bf8c18;hb=e030a6e31232332b73187eda25870e843152c174;hpb=31f7d913d4a99d0a4db9bcfe40e31cebf90b22e6 diff --git a/R/plot.R b/R/plot.R index f551ef4..9a0dbcd 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) + range(serie, na.rm=TRUE) + c() }) ) grays = gray.colors(20, 0.1, 0.9) #TODO: 20 == magic number colors = c(