Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • line connectors in pie plot for too small slices

    Dear Stata uses,

    I seldom use pie plot, people often point out its flaws. But I have to use it for a report, layman seems to like pie chart (maybe human do like circle). If you use the following codes to graph a pie plot, you will find that in some slices there are overlap of plabels. In this data example, slices represent manager, profession, technician and selfemp categories are too small to label. I wonder is there some way to put the plabels outside the slice or apart from each other, and use some line connectors to connecte the corresponding slices. Thank you.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(ratio1 ratio2 ratio3 ratio4 ratio5 ratio6 ratio7 ratio8)
    .2991214 .011514423 .020533217 .2432774 .021481434 .2438631 .010377994 .09076492
    end
    Code:
    local la "farmer manager profession student technician worker selfemp others"
    forvalues n = 1/8 {
     local nla: word `n' of `la'
     label var ratio`n' "`nla'"
     }
     
    graph pie ratio*, sort descending legend(posi(6) row(4)) plabel(_all percent, format(%2.1f)) plotregion(style(none))

  • #2
    Pies make sense when they show proportions of a total. They often work poorly then, but they make sense. Your "ratio" doesn't sum to 1, so pie charts are ruled out on that basis. I won't even try to improve your pie code, just suggest that you insist on something different.

    Code:
    clear
    input float(ratio1 ratio2 ratio3 ratio4 ratio5 ratio6 ratio7 ratio8)
    .2991214 .011514423 .020533217 .2432774 .021481434 .2438631 .010377994 .09076492
    end
    
    gen id = 1 
    reshape long ratio, i(id) j(which) 
    tokenize "farmer manager profession student technician worker selfemp others"
    
    su ratio 
    di r(sum) 
    
    forval i = 1/8 { 
        label def which `i' "``i''" , modify 
    } 
    label val which which 
    
    graph hbar (asis) ratio, over(which, sort(1) descending) bar(1, bfcolor(blue*0.2) blcolor(blue)) ytitle(ratio) ysc(alt)
    Click image for larger version

Name:	notapie.png
Views:	1
Size:	28.6 KB
ID:	1469845

    Comment


    • #3
      Thank you Nick, I learn more through reading your codes. Please allow me to cite some remarks in Quick-R site, although it's a bit inappropriate to cite R in a Stata forum:
      Pie charts are not recommended in the R documentation, and their features are somewhat limited. The authors recommend bar or dot plots over pie charts because people are able to judge length more accurately than volume.
      As to the pie chart, there's still some audience, readers and sponsors in need of it, but in a more beautiful form, more stereoscopic, more colorful and no overlaping plables. However -tabplot- be a more scientific demonstration tool, non-professional people read traditional bar plot more easily.
      https://stackoverflow.com/questions/...-charts-with-r
      Click image for larger version

Name:	pieplot.png
Views:	1
Size:	541.9 KB
ID:	1469853

      Comment


      • #4
        Nick Cox wrote a command -pieplot- in 2009 (from SSC). -pieplot- plots pie charts of categorical frequencies. As it described in help file, this command is a convenience command providing an alternative to graph pie, over() for pie charts showing categorical frequencies. (Only a memo.)

        Comment


        • #5
          Hope that graph pie can create 'rectangles' easily.
          https://www.statalist.org/forums/forum/general-stata-discussion/general/1483934-help-with-spmap-legend-option
          https://www.statalist.org/forums/for...horopleth-maps
          Last edited by Chen Samulsion; 11 Mar 2019, 07:29.

          Comment


          • #6
            I guess you can do some of that in the Graph Editor.

            Otherwise I can't whip up any enthusiasm for this, even for someone else taking time to automate this.

            Making a lousy graph slightly less lousy is not a good use of anyone's time when a better one is easy. Naturally, that's just one opinion.

            Comment


            • #7
              OK, Nick, I can remove pie chart from my toolkit, using bar chart, box plot or dot plots as substitutes for it.

              Comment

              Working...
              X