An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091125/654989c6/attachment-0001.pl>
Plot and area below a line graph
2 messages · Jose Narillos de Santos, Achim Zeileis
On Wed, 25 Nov 2009, Jose Narillos de Santos wrote:
Imagine I have a variable X I use plot (X, type="l"). I want to "show" with colour the area between "the line of X" and the Zero Axis. So that if X have negative values the colored area will be below zero. I?m trying to make this with polygons() but I?m not able.... Can you guide me to do it?
Maybe something like this? ## artificial random walk set.seed(123) x <- cumsum(rnorm(100)) ## plot plot(x, type = "l") ## add shaded polygon polygon(c(1, 1:100, 100), c(0, x, 0), col = "lightgray") ## zero axis abline(h = 0, lwd = 2, col = "blue") hth, Z
The other question is how can I show "the zero axis" in a plot? [[alternative HTML version deleted]]