cumulative distributions for several groups

38 views
Skip to first unread message

erich studerus

unread,
Feb 16, 2009, 2:48:48 PM2/16/09
to ggplot2
Hello,

I want to show the cumulative distribution functions of several groups
within one plot. When I use the geom_step function the lines get
connected between different groups. Is there a way to avoid this? I
want geom_step behaving the same way as geom_line. Here's an example:

x <- sort(rnorm(47))
df1<-data.frame(y=x,x=seq_along(x),z='A')
x <- sort(rnorm(47))
df2<-data.frame(y=x,x=seq_along(x),z='B')
df <-rbind(df1,df2)
qplot(data=df,x=x,y=y,colour=z)+geom_step() #lines get scrambled
qplot(data=df,x=x,y=y,colour=z)+geom_line() #lines from different
groups are separated

Thanks a lot!

David Kahle

unread,
Feb 16, 2009, 5:47:24 PM2/16/09
to erich studerus, ggplot2
Hi Erich -

Attached is a function I just put together which will plot empiricals
for a vector of samples or a list containing many samples (which is
what I think you're looking for). The function is in the file
attached along with some examples on the bottom. Let me know how it
goes!

Cheers
david.

ggecdf.R

erich studerus

unread,
Feb 16, 2009, 8:35:59 PM2/16/09
to ggplot2
Thanks a lot! I managed to adapt your code for my special needs.

Cheers

Erich
>  ggecdf.R
> 1KAnzeigenHerunterladen

hadley wickham

unread,
Feb 16, 2009, 10:02:58 PM2/16/09
to erich studerus, ggplot2
And I've just fixed the bug in the development version :)
Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages