James,
Yes, I've tried exactly that, and several variations thereupon. But if
you run this code, you'll see that while the factors get resorted in
the legend, and the colors are shuffled, their respective bands get
stacked in the same order.
d <- melt(data.frame(week = sequence(52), "panda","kitten","whale"), c
("week"))[-2]
d$eaten<-rpois(52*3, 2) #because using the poisson distribution makes
it Science.
p1 <- ggplot(d, aes(x=week, y=eaten, group=value)) + geom_area(aes
(fill=value))
d$value <- factor(d$value, levels=c("whale", "kitten", "panda"))
p2 <- ggplot(d, aes(x=week, y=eaten, group=value)) + geom_area(aes
(fill=value))
grid.newpage()
pushViewport(viewport(layout=grid.layout(2,1)))
vplayout<-function(x,y)
viewport(layout.pos.row=x,layout.pos.col=y)
print(p1,vp=vplayout(1,1))
print(p2,vp=vplayout(2,1))
On Dec 4, 1:00 pm, James Howison <
ja...@freelancepropaganda.com>
wrote: