Dimitri Liakhovitski
2011-Jul-21 15:29 UTC
[R] squared "pie chart" - is there such a thing?
Hello! It's a shoot in the dark, but I'll try. If one has a total of 100 (e.g., %), and three components of the total, e.g., mytotal=data.frame(x=50,y=30,z=20), - one could build a pie chart with 3 sectors representing x, y, and z according to their proportions in the total. I am wondering if it's possible to build something very similar, but not on a circle but in a square - such that the total area of the square is the sum of the components and the components (x, y, and z) are represented on a square as shapes with right angles (squares, rectangles, L-shapes, etc.). I realize there are many possible positions and shapes - even for 3 components. But I don't really care where components are located within the square - as long as they are there. Is there a package that could do something like that? Thanks a lot! -- Dimitri Liakhovitski marketfusionanalytics.com
This is called a squarified pie chart or a waffle chart (if you want to keep the food metaphor going): http://eagereyes.org/communication/Engaging-readers-with-square-pie-waffle-charts.html Hadley On Thu, Jul 21, 2011 at 10:29 AM, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote:> Hello! > It's a shoot in the dark, but I'll try. If one has a total of 100 > (e.g., %), and three components of the total, e.g., > mytotal=data.frame(x=50,y=30,z=20), - one could build a pie chart with > 3 sectors representing x, y, and z according to their proportions in > the total. > I am wondering if it's possible to build something very similar, but > not on a circle but in a square - such that the total area of the > square is the sum of the components and the components (x, y, and z) > are represented on a square as shapes with right angles (squares, > rectangles, L-shapes, etc.). I realize there are many possible > positions and shapes - even for 3 components. But I don't really care > where components are located within the square - as long as they are > there. > > Is there a package that could do something like that? > Thanks a lot! > > -- > Dimitri Liakhovitski > marketfusionanalytics.com > > ______________________________________________ > R-help at 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. >-- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
It's more complex than what you describe, but what about a mosaic plot? http://conprogram.weebly.com/program-schedule.html They're very useful, and much better than pie charts because they don't rely on the visual estimation of angles, something people aren't very good at. Sarah On Thu, Jul 21, 2011 at 11:29 AM, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote:> Hello! > It's a shoot in the dark, but I'll try. If one has a total of 100 > (e.g., %), and three components of the total, e.g., > mytotal=data.frame(x=50,y=30,z=20), - one could build a pie chart with > 3 sectors representing x, y, and z according to their proportions in > the total. > I am wondering if it's possible to build something very similar, but > not on a circle but in a square - such that the total area of the > square is the sum of the components and the components (x, y, and z) > are represented on a square as shapes with right angles (squares, > rectangles, L-shapes, etc.). I realize there are many possible > positions and shapes - even for 3 components. But I don't really care > where components are located within the square - as long as they are > there. > > Is there a package that could do something like that? > Thanks a lot! > > -- > Dimitri Liakhovitski > marketfusionanalytics.com >-- Sarah Goslee http://www.functionaldiversity.org
On Thu, Jul 21, 2011 at 11:29 AM, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote:> Hello! > It's a shoot in the dark, but I'll try. If one has a total of 100 > (e.g., %), and three components of the total, e.g., > mytotal=data.frame(x=50,y=30,z=20), - one could build a pie chart with > 3 sectors representing x, y, and z according to their proportions in > the total. > I am wondering if it's possible to build something very similar, but > not on a circle but in a square - such that the total area of the > square is the sum of the components and the components (x, y, and z) > are represented on a square as shapes with right angles (squares, > rectangles, L-shapes, etc.). I realize there are many possible > positions and shapes - even for 3 components. But I don't really care > where components are located within the square - as long as they are > there. > > Is there a package that could do something like that? > Thanks a lot!Check out the treemap package. See the bottom of this page for examples: http://www.oga-lab.net/RGM2/func.php?rd_id=treemap:treemap-package -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Hello! It's a shoot in the dark, but I'll try. If one has a total of 100 (e.g., %), and three components of the total, e.g., mytotal=data.frame(x=50,y=30,z=20), - one could build a pie chart with 3 sectors representing x, y, and z according to their proportions in the total. I am wondering if it's possible to build something very similar, but not on a circle but in a square - such that the total area of the square is the sum of the components and the components (x, y, and z) are represented on a square as shapes with right angles (squares, rectangles, L-shapes, etc.). I realize there are many possible positions and shapes - even for 3 components. But I don't really care where components are located within the square - as long as they are there. Is there a package that could do something like that? Thanks a lot! ----- I included waffle charts in Creating More Effective Graphs. The reaction was very negative; many readers let me know that they didn't like them. To create them I just drew a table in Word with 10 rows and 10 columns. Then I shaded the backgrounds of cells so for your example we would shade 50 cells one color, 30 another, and 20 a third color. Naomi ------------- Naomi B. Robbins 11 Christine Court Wayne, NJ 07470 973-694-6009 naomi@nbr-graphs.com <mailto:naomi@nbr-graphs.com> http://www.nbr-graphs.com Author of Creating More Effective Graphs <http://www.nbr-graphs.com/bookframe.html> // [[alternative HTML version deleted]]