# Kite diagrams

8 messages
Open this post in threaded view
|

## Kite diagrams

 I teach biology, and would like to show the students how to use R for some statistical assignments. One of those is to make a kite diagram (for example as seen in http://www.medinavalleycentre.org.uk/images/Bembri1.jpg). Is there any way to create one using R? I did a help.search("kite") and looked on the r-project HP with no luck. Previously when the course was taugh the students have either abused MS Exel or drawn the diagrams by hand. /Par -- Par Leijonhufvud                               [hidden email] Imagine a codebase billions of years old, neveer taken off line, never maintained by professionals, and hacked on by every damn luser who came along and felt like a bit of whopee.    -- Johan Larson ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Open this post in threaded view
|

## Re: Kite diagrams

 Par Leijonhufvud wrote: > I teach biology, and would like to show the students how to use R for > some statistical assignments. One of those is to make a kite diagram > (for example as seen in > http://www.medinavalleycentre.org.uk/images/Bembri1.jpg). Is there any > way to create one using R? I did a help.search("kite") and looked on the > r-project HP with no luck.   The joy of R is that of course there is a way to create these - you just have to write the code!   The data are, I guess, on the X-axis a discrete set of distance points, (identical for each species?), and then for each species an abundance measurement - is this continuous or discretized, or does it only take the values shown on the key ('ACFOR' = Abundant, Common, Frequent, Occasional, Rare??). Looking at the kites I'd guess the data are numbers and nearly-continuous.   Anyway, you can use plot() with type='n' to set out a blank plot with X-axis according to your distance scale and a Y-axis of something like 1:Nspecies, then use the polygon() function to draw the little kites, making sure you dont draw anything between separated kites. This probably means several polygon() calls or sticking NA's in the coordinates.   Adding the little cross-section of the shoreline at the top is possible too... > Previously when the course was taugh the students have either abused MS > Exel or drawn the diagrams by hand.   Whereas now they can just rely on the goodwill of R-help to do it! :)   Why do these interesting questions always seem to occur on a Monday morning when I really dont want to get on with the stuff I'm supposed to be doing.... Barry ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Open this post in threaded view
|

## Re: Kite diagrams

 Barry Rowlingson <[hidden email]> [2006.01.16] wrote: >  The joy of R is that of course there is a way to create these - you > just have to write the code! Ok. time to start learning... >  The data are, I guess, on the X-axis a discrete set of distance > points, (identical for each species?), and then for each species an > abundance measurement - is this continuous or discretized, or does it > only take the values shown on the key ('ACFOR' = Abundant, Common, > Frequent, Occasional, Rare??). Looking at the kites I'd guess the data > are numbers and nearly-continuous. In our case I would expect them to mostly be numbers, as continous as real world things actually get, but sometimes only ACFOR. That is, I need to code it to handle both cases. >  Anyway, you can use plot() with type='n' to set out a blank plot with > X-axis according to your distance scale and a Y-axis of something like > 1:Nspecies, then use the polygon() function to draw the little kites, > making sure you dont draw anything between separated kites. This > probably means several polygon() calls or sticking NA's in the coordinates. > >  Adding the little cross-section of the shoreline at the top is > possible too... > > >Previously when the course was taugh the students have either abused MS > >Exel or drawn the diagrams by hand. > >  Whereas now they can just rely on the goodwill of R-help to do it! :) I *was* hoping for "use the kite package from CRAN, silly", but pointers on how to code such a package myself is ok. Good practice, and a way to repay R for all the use I've gotten from it. Knowing students I not only need to make it work, but also write drool-proof instructions for how to use it. :-) >  Why do these interesting questions always seem to occur on a Monday > morning when I really dont want to get on with the stuff I'm supposed to > be doing.... Because the universe loves you and hates your employer. Or vice versa. /Par -- Par Leijonhufvud                               [hidden email] `You know, there's a word for people who  think that everyone is out to get them...' `Yes! Perceptive!'           --Woody Allen ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Open this post in threaded view
|

## Re: Kite diagrams

 In reply to this post by Par Leijonhufvud Hi Par, I am trying to do the exact same thing with my class, I would like to use R too, as well as get them to draw it out. I have tried to follow the suggestions but with no luck. If you did get round to sorting the code I wondered if you'd be so kind as to let me into the secret on how to do it?! Best wishes, Ross
Open this post in threaded view
|

## Re: Kite diagrams

 On 07/02/2010 04:06 PM, RCulloch wrote: > > Hi Par, > > I am trying to do the exact same thing with my class, I would like to use R > too, as well as get them to draw it out. I have tried to follow the > suggestions but with no luck. If you did get round to sorting the code I > wondered if you'd be so kind as to let me into the secret on how to do it?! > This looks very much like the example I sent in for the request: Re: [R] Stacked Histogram, multiple lines for dates of news stories? I should have a function written to do that plot this week, so I'll post it on the list if anyone else is interested. Jim ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Kite diagrams

 I asked the same question on  R-sig-eco, and Ben Bolker provided this solution, which as I assume this should show up in a search I copy here. However, if someone can come up with a single function, that would be good. ------------------------------------------------------------------------------------------------------------------  I don't do kite diagrams at all, but here are some quick & dirty solutions. ## inspired by violin plots in: ## http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-3/X <- read.table(textConnection("dist spA spB spC 0 0 0 0 5 0 4 0 10 0 20 0 15 5 30 0 20 10 20 0 25 20 8  4 30 15 2  5 35 5  0  10 40 0  0  20 45 0  0  10 50 0  0  5 55 0  0  0"),header=TRUE) library(reshape) mX <- melt(X,id.var="dist") names(mX)[2:3] <- c("species","abundance") mX\$fabund <- cut(mX\$abundance,                  breaks=c(-0.01,0,5,20,100),                  labels=c("Abs","Rare","Common","Abundant")) library(ggplot2) p <- ggplot(mX, aes(x=dist)) ## plot by proportion p + geom_ribbon(aes(ymax = -abundance, ymin = +abundance))+   facet_grid(species ~ .) ## plot by abundance category p + geom_ribbon(aes(ymax = as.numeric(fabund)-1,                     ymin = -(as.numeric(fabund)-1)))+   facet_grid(species ~ .) -- Ben Bolker Associate professor, Biology Dep't, Univ. of Florida [hidden email] / people.biology.ufl.edu/bolker GPG key: people.biology.ufl.edu/bolker/benbolker-publickey.asc ------------------------------------------------------------------------------------------------------------------------------------ Graham ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.