Kim
unread,Jun 22, 2010, 3:16:24 PM6/22/10Sign 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
Hi there,
Is there an easy way to create a waterfall plot using ggplot2?
Here is how I create a waterfall plot without using ggplot2:
absXY= c( -1.0 ,-0.4 ,-0.3, -0.5, -0.2 ,-0.2, -0.5 ,-0.3 ,-0.5 , 0.0 ,
0.0 , -0.3, -0.2 ,-0.6 ,-0.2, -0.2, 0.0, 0.0 ,-0.5, -0.2 ,
0.0 ,-0.3 ,-0.4, -0.8 ,-0.3 , 0.0 , 0.0 , 0.0, -0.5 ,0.0, -0.1 ,
0.0 ,-0.1 ,-0.4, -0.2 ,-1.7 ,-0.8 , 0.0 ,0.0 ,-0.2,
-0.1 ,-0.2 ,-0.3 , -0.3 ,-0.1, 0.0 ,-0.4, -0.1 , 0.0 , 0.0 ,-0.2,
-0.1, -0.5 , 0.2 , 0.6 , 0.7, 0.6 , 1.2, 1.0 , 0.3,
0.8 , 2.0, 0.2 , 0.1 , 1.3 , 0.6, 1.1 , 0.3 , 1.2 , 0.8 , 0.4,
0.3 , 0.3, 0.9 , 0.1, 0.2 ,0.4 , 0.4, 0.2 , 0.4 , 0.9 , 0.5 ,
0.2 , 0.3, 0.5, 0.1 , 1.6 , 1.0, 0.4 , 1.6, 1.2 ,0.5, 0.6 ,
1.1 , 3.8 , 0.8 , 0.2 , 0.5 , 1.1 , 1.7 ,0.4 , 0.2 , 0.4, 1.7 ,
0.2, 0.8 ,0.5, 0.1 , 1.2 , 0.6 , 0.1, 0.4, 0.5 ,0.4 ,0.1 ,
0.3 , 0.1 , 0.3, 0.8 , 0.4, 1.4 ,0.2, 0.1 , 0.4 ,0.1 , 0.8,
0.6 , 0.8 , 0.1 , 0.1, 0.9 , 0.5 ,0.2, 0.9, 0.3, 0.2 , 0.1 ,
0.2 ,0.1, 0.9, 2.6 , 0.3 ,0.6, 0.3 , 0.1 )
sort.absXY= absXY[order(absXY)]
plot(sort.absXY, type='h')
axis(side=3, at=c(0:10)*14.5, label=c(0:10)*10, xlab='% of Cases')
I think that waterfall plots may be preferable to histograms in some
instances because you can easily tell what proportion of individuals
have a value below a certain threshold. Waterfall plots also clearly
distinguish the proportion of people with negative, positive, and 0
values.
I'd like to find a way to create waterfall plots using ggplot2 so that
I can then use ggplot2 to do cooler things, like creating a line
rather than the bars in the current waterfall plot, and having a
separate line for different subgroups, and also to use the faceting
options. I may be able to do all this without using ggplot2, but I
kind of feel like it might be easier in ggplot2.
Thanks a bunch for your help/suggestions,
Kim