[R] ThinkCell type waterfall charts in R?

Greg Snow Greg.Snow at imail.org
Tue Feb 3 18:28:16 CET 2009


Without knowing how your data is formatted or how you intend to link the information together, all we can do is reconsctruct the plot from scratch.  Here is one way to do that (change whatever values you want to tweek the look):

plot( c(1,10), c(0,95), type='n', axes=F, xlab='', ylab='', xlim=c(0,11),
	ylim=c(0,150) )

left <- (1:10) - 0.3
right <- (1:10) + 0.3
top <- c(86,86, 86-18, 55, 55, 55-5, 55-5-8, 32, 32, 23)
bottom <- c(0, 86-18, 55, 0, 55-5, 55-5-8, 32, 0, 32-9, 0)
vals <- c(86, 18, 13, 55, 5, 8, 10, 32, 9, 23)
val.y <- (top+bottom)/2
val.y[ bottom==0 ] <- top[ bottom==0 ] + 5

cols <- c('#bfcad7', '#ffffff', '#ffffff', '#8094af', '#ffffff', '#ffffff', '#ffffff', 
	'#405e88', '#ffffff', '#405e88')

rect( left,bottom,right,top, col=cols )
text( 1:10, val.y, vals )

lines( c(0.5, 10.5), c(0,0), lwd=5, lend='round')
segments( right[-10], top[-1], left[-1], top[-1], lty='dashed' )

axis(1, at=1:10, labels=c('Registered\nprojects', rep('',9)), tick=FALSE,
	cex.axis=.5)

Now that you can see one way to reconstruct the plot, I would add that I think this particular plot is not the best way to convey the information (the first example was a complete failure).  It looks more like a poorly laid out table than a useful plot, why not just arrange the data as a table (with the numbers lined up properly and grouped according to your information) rather than as a plot that is more difficult to read.


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Kerstin
> Sent: Tuesday, February 03, 2009 3:31 AM
> To: Jim Lemon
> Cc: r-help at r-project.org
> Subject: Re: [R] ThinkCell type waterfall charts in R?
> 
> Jim Lemon wrote:
> > Kerstin wrote:
> >> Hi all,
> >>
> >> with PowerPoint and ThinkCell one can draw something they call
> >> waterfall chart and it looks like this:
> >> http://www.think-cell.com/products/images/waterfall.gif
> >>
> >> I found discussions on waterfall charts in the archive of this
> >> mailinglist, but unfortunately they looked totally different. Other
> >> names for this type of plot seem to be bridge chart, cascade chart,
> >> stair case chart, etc. but neither of them brought successful
> >> results. So I decided to ask you directly on the list.
> >>
> >> Does anyone have an idea on how I could plot this type of chart in
> R?
> > Well Kirsten, it's a real challenge trying to find something that you
> > _can't_ plot in R. Perhaps if you sent some data to the mailing list
> > and a description of how the various counts (?) are related to one
> > another, some R-nut may reply with what you want.
> >
> > Jim
> Thanks a lot for your quick reply.
> 
> In the attached pdf you can see the chart I would like to draw with R.
> I
> could of course make my life easier and use the Power Point chart, but
> importing a ppt chart into Latex would not make me sleep very well,
> besides the fact that all other plots in my document will come from R
> and I don't want this one to look totally different...
> 
> Cheers
> Kerstin




More information about the R-help mailing list