Okay - first off: Thank you all for you kind help so far. (Especially
to hadly for writing ggplot2). I feel that I am beginning to
understand the grammar of graphics - but obviously still have a long
way to go. Some of the road I need to travel has to do with basic R.
Anyway ; instead of wrting a new post - I thought it best to post in
the current topic. please correct me if I am wrong.

getting to the point: I have expanded upon the original bumps chart
(or what ever type of chart it is). I'd like the line width to be
proportional to the change between time 1 and time 2. Also: I'd like
colous to be red if the change is negative, and black if the change is
positive.

My solutions produces some problems for me:

library(ggplot2) # Loads ggplot2
text <- letters[1:20] # letters is proxy for categories
tal1 <- rnorm (20,5,2) # random numbers for first
tal2 <- rnorm (20,6,3) # random numbers for second
dif <- tal2-tal1 # difference between second and first
df0 <- cbind(tal1,tal2,dif) # do dataframe
df <- melt(df0) # melt
farve <- c(2,1,1,2,2,1,2,2,2,2,1,1,1,2,2,1,1,1,2,2) # define colours -
black for positive change, red for negative change
# these colours I handcode - depending on the random generated - so it
will not fit new data.

# draw the plot
qplot(X2, value,data=df,  group=X1,geom="blank")+
 
geom_line(aes(group=X1),subset(df,X2!="dif"),size=scale(abs(subset(df,df$X2=="dif")$value),center=F,scale=T)[,1],colour=farve)+
 
geom_text(aes(label=X1),subset(df,X2=="tal2"),size=3,hjust=-3,vjust=1)+theme_bw()

# My questions:
# How to do colours automaticaly
# how to remove "dif" from the X axis? - subset doesn't seem to work? - eg
# qplot(subset(df,X2!="dif",X2, drop=T), value,data=df) - returns an error.
# Hot to use melt better - so that text becomes the id? id=text doesn't work.

thanks in advance

On Tue, Apr 28, 2009 at 12:09 AM, Andreas Christoffersen
<achristoffer...@gmail.com> wrote:
>
> My legend is removed! - Couldn't find it in your ggplot2 book - but
> here it is. Brilliant - thank you very much.
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to