Skip to content
Back to formatted view

Raw Message

Message-ID: <f8e6ff050809191057n1dc18494m92b540d9cafdad0f@mail.gmail.com>
Date: 2008-09-19T17:57:53Z
From: Hadley Wickham
Subject: Coloring spaces between lines in xyplot
In-Reply-To: <OF793328A0.015C7631-ON882574C8.00798750-882574C8.007A31D7@fs.fed.us>

On Thu, Sep 18, 2008 at 5:14 PM, Seth W Bigelow <sbigelow at fs.fed.us> wrote:
>
> Greetings:
>  I wish to create a stacked line graph in xyplot, adding color to the
> spaces between the lines. For example, the code below creates a plot with
> two lines extending across it, and I want to color the rhomboid that is
> between the upper and lower line, and between the lower line and the bottom
> of the frame.
> Suggestions appreciated

Well, if you relax the condition to use lattice, try

install.packages("ggplot2")
library(ggplot2)

x <- rep(seq(1,10), 2)
y <- c(1+1.5*(1:10), 0.2 + 1.3*(1:10) )
trt <- rep(c("low", "high"), each = 10)

qplot(x, y, fill=trt, geom="area")

Hadley

-- 
http://had.co.nz/