Etienne B. Racine
unread,Jun 9, 2009, 8:47:41 AM6/9/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
When I plot a stacked area chart, I get some holes and the areas are
misordered because some lines are missing. Instead of 0 values, there
is simply no line. How can I tell ggplot to put 0 when there is
nothing ?
Example :
set.seed(1001)
df <- data.frame(
cat = rep(letters[1:4], each = 10),
xax = rep(1:10, 4),
value = floor(rlnorm(40))
)
# this is working great :
qplot(x=xax, y=value, data=df, geom="area", fill = cat,
position="fill")
# but what I really have is looking like that :
df0 <- df[df$value!=0,]
qplot(x=xax, y=value, data=df0, geom="area", fill = cat,
position="fill")
I could generate all the combinations (using expand.grid), but I think
it would make something huge and it wouldn't be very dynamic to
update. Is there another way.
Etienne