Skip to content

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:

            
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