Re: [R] Adding percentage to Pie Charts
Gabor Grothendieck ggrothendieck at gmail.com writes: It might also be nice to be able to align the fans at the left or right, not just the center. Fans that open only on one side: A line that moves like the minute needle of an analog clock; with zero at the top. Movement of the needle in clock-wise direction represents the number (precentage). Anupam. __ R-help@stat.math.ethz.ch 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.
Re: [R] Adding percentage to Pie Charts
Hi all, Anupam Tyagi mentioned an interesting idea a few days ago. A modification in a pie chart that draws overlapping areas with a common start point at the top of the circle, can make is more informative than a dot-chart. Something like: * Start drawing at the top of the circle, as zero (degree/area). * Draw the representation of every value starting from the top, as zero, representing it as a labled line from the center of the circle to the boundary (can use colors where possible). * Use two lables for the circular axis, inside one for percentages, outside for values. I admit to interpreting this pretty loosely, but I would like to know what people think of a fan plot. fan.plot-function(x,edges=200,radius=1,col=NULL,centerpos=pi/2, labels=NULL,...) { if (!is.numeric(x) || any(is.na(x) | x=0)) stop(fan.plot: x values must be positive.) # scale the values to a half circle x-pi*x/sum(x) xorder-order(x,decreasing=TRUE) nx - length(x) if (is.null(col)) col-rainbow(nx) else if(length(col) nx) col-rep(col,nx) oldpar-par(no.readonly=TRUE) par(mar=c(0,0,4,0)) plot(0,xlim=c(-1,1),ylim=c(-0.6,1),xlab=,ylab=,type=n,axes=FALSE) lside--0.8 for(i in 1:nx) { n-edges*x[xorder[i]]/pi t2p-seq(centerpos-x[xorder[i]],centerpos+x[xorder[i]],length=n) xc-c(cos(t2p)*radius,0) yc-c(sin(t2p)*radius,0) polygon(xc,yc,col=col[xorder[i]],...) if(!is.null(labels)) { xpos-lside*sin(x[xorder[i]])*radius ypos--i/10 text(xpos,ypos,labels[xorder[i]]) ytop-cos(x[xorder[i]])*radius*radius segments(xpos,ypos+1/20,xpos,ytop) lside--lside } radius-radius-0.02 } } Jim __ R-help@stat.math.ethz.ch 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.
Re: [R] Adding percentage to Pie Charts
It might also be nice to be able to align the fans at the left or right, not just the center. On 9/23/06, Jim Lemon [EMAIL PROTECTED] wrote: Hi all, Anupam Tyagi mentioned an interesting idea a few days ago. A modification in a pie chart that draws overlapping areas with a common start point at the top of the circle, can make is more informative than a dot-chart. Something like: * Start drawing at the top of the circle, as zero (degree/area). * Draw the representation of every value starting from the top, as zero, representing it as a labled line from the center of the circle to the boundary (can use colors where possible). * Use two lables for the circular axis, inside one for percentages, outside for values. I admit to interpreting this pretty loosely, but I would like to know what people think of a fan plot. fan.plot-function(x,edges=200,radius=1,col=NULL,centerpos=pi/2, labels=NULL,...) { if (!is.numeric(x) || any(is.na(x) | x=0)) stop(fan.plot: x values must be positive.) # scale the values to a half circle x-pi*x/sum(x) xorder-order(x,decreasing=TRUE) nx - length(x) if (is.null(col)) col-rainbow(nx) else if(length(col) nx) col-rep(col,nx) oldpar-par(no.readonly=TRUE) par(mar=c(0,0,4,0)) plot(0,xlim=c(-1,1),ylim=c(-0.6,1),xlab=,ylab=,type=n,axes=FALSE) lside--0.8 for(i in 1:nx) { n-edges*x[xorder[i]]/pi t2p-seq(centerpos-x[xorder[i]],centerpos+x[xorder[i]],length=n) xc-c(cos(t2p)*radius,0) yc-c(sin(t2p)*radius,0) polygon(xc,yc,col=col[xorder[i]],...) if(!is.null(labels)) { xpos-lside*sin(x[xorder[i]])*radius ypos--i/10 text(xpos,ypos,labels[xorder[i]]) ytop-cos(x[xorder[i]])*radius*radius segments(xpos,ypos+1/20,xpos,ytop) lside--lside } radius-radius-0.02 } } Jim __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] Adding percentage to Pie Charts (was (no subject))
Greg Snow Greg.Snow at intermountainmail.org writes: Have you read the books by Cleveland? I do not recall reading Cleveland's book; I have read one by Tufte. You raise some interesting issues there. I agree with some, I could not clearly understand some other things you mention. I think visual perception is aquired, in part. So if I were presenting data to viewers who took carpentry or other such classes in highschool I may be tempted to use dotcarts. An interesting experiment: have kids compare pieces of pie or bread-sticks over a dinner, and check how they do. They should not have taken a carpentry class. I use dot-charts, they are useful. Sometimes pie carts are useful too, because people are so used to using and seeing them over a long time. Ofcourse, they can be improved. Also, it may be possible to put points of a dot-chart on a single straight line, label them with a pointing line, and get better perception. There is poor perception of the horizantal distance, by having to view that extra vertical distance in a dotchart. However, it is useful to have the vertical axis in Lattice plots, but not in stand-alone dot-charts. Anupam. __ R-help@stat.math.ethz.ch 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.
Re: [R] Adding percentage to Pie Charts (was (no subject))
Greg Snow Greg.Snow at intermountainmail.org writes: You may want to rethink your whole approach here: 1. Pie charts are usually a poor choice of graph, there are better choices. 2. Adding percentages to a pie chart is a way of admitting that the pie chart is not doing the job. 3. If you want people to compare percentages, then a table is what is needed. 4. A pie chart with percentages added is essentially a colorful but poorly layed out table. Consider using a dotplot instead of a pie chart, it changes the job of the viewer from comparing areas/angles (done poorly by humans) to comparing positions along a common scale (done well by humans). I think dot charts (plots) are very useful, but they are not substitutes for a pie chart: they do not show a comparison between the total and the individual value; have a different scale (linear, usually), and are visually not suitable to answer some questions that a pie chart can answer (is the value approximately less than a fourth of the total? Is it less than half?). For some of these questions, even dot-charts require a value label, or the user doing mental calculations to guess approximations. I think I am quite attuned to getting approximate fractions from a pie-chart in shorter time, than on a linear scale like the dot-chart. A modification in a pie chart that draws overlapping areas with a common start point at the top of the circle, can make is more informative than a dot-chart. Something like: * Start drawing at the top of the circle, as zero (degree/area). * Draw the representation of every value starting from the top, as zero, representing it as a labled line from the center of the circle to the boundary (can use colors where possible). * Use two lables for the circular axis, inside one for percentages, outside for values. What is the simplest way to draw this in R? Anupam. __ R-help@stat.math.ethz.ch 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.
Re: [R] Adding percentage to Pie Charts (was (no subject))
Have you read the books by Cleveland? His experiments show that most people do better estimating things and comparing things on a linear scale rather than looking at angles and areas (also see http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatGraphCourse/graphsco urse.pdf) With a dot chart you can set the axis to go from 0 to the total of all groups (see the example I sent before, it could have had the numbers on the x-axis, but still included the total), that means that points near the middle of the line represent about 50%, looking at how close the point is to the left lets you estimate the percentage and most people (you may differ) do a better job of estimating that percentage from the position of the dot than from an angle or area. If you feel the need to specify the percentages along the side of a dot chart, then at least they are lined up vertically for easy comparison (my example would have been better if a lot of the vertical space had been removed so the pieces of interest were closer together), the pie chart would generally have the percentages non-aligned causing more work for the viewer to compare them. Dotcharts also remove the dependence/temptation to use color and any psycolocical influences that may have on the interpretation. I have yet to see a pie chart that was better at conveying the true nature of the data than a well done dot chart of the same data, I have seen multiple cases where the dot chart showed truths about the data that were not apparent in the corresponding pie chart. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anupam Tyagi Sent: Tuesday, September 19, 2006 12:52 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] Adding percentage to Pie Charts (was (no subject)) Greg Snow Greg.Snow at intermountainmail.org writes: You may want to rethink your whole approach here: 1. Pie charts are usually a poor choice of graph, there are better choices. 2. Adding percentages to a pie chart is a way of admitting that the pie chart is not doing the job. 3. If you want people to compare percentages, then a table is what is needed. 4. A pie chart with percentages added is essentially a colorful but poorly layed out table. Consider using a dotplot instead of a pie chart, it changes the job of the viewer from comparing areas/angles (done poorly by humans) to comparing positions along a common scale (done well by humans). I think dot charts (plots) are very useful, but they are not substitutes for a pie chart: they do not show a comparison between the total and the individual value; have a different scale (linear, usually), and are visually not suitable to answer some questions that a pie chart can answer (is the value approximately less than a fourth of the total? Is it less than half?). For some of these questions, even dot-charts require a value label, or the user doing mental calculations to guess approximations. I think I am quite attuned to getting approximate fractions from a pie-chart in shorter time, than on a linear scale like the dot-chart. A modification in a pie chart that draws overlapping areas with a common start point at the top of the circle, can make is more informative than a dot-chart. Something like: * Start drawing at the top of the circle, as zero (degree/area). * Draw the representation of every value starting from the top, as zero, representing it as a labled line from the center of the circle to the boundary (can use colors where possible). * Use two lables for the circular axis, inside one for percentages, outside for values. What is the simplest way to draw this in R? Anupam. __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.