On 26/05/2016 5:37 AM, Óscar Jiménez wrote:
Hello,

I'm working with R language, and plotting some parameters over time. I need
to draw a shaded area under the curve of eacj parameter.

For that, I might use the polygon (x,y) function, assigning coordinates
(x,y) to each vertex of my polygon. To do so, "x" and "y" must be vectors
with numerical values, but since my x-axis is a time series, I cannot
assing a numerical value to my "x" coordinate, because time variable is a
"character" variable.

Is there any option to use the function polygin (x,y) in this case, or any
other function that allows me to draw a shaded area under the curve on a
time series basis?

Times and dates just print like characters, they aren't actually characters. For example,

 x <- Sys.Date() + 1:20
 y <- rnorm(20)
 plot(y ~ x)
 polygon(c(x, x[20], x[1]), c(y, 0, 0), col="gray")

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to