Announcement

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

  • Creating multiple graphs using by - possible to also sort?

    Hello,

    I am creating multiple versions of the same graph by a variable (experience). I'm using the following code:

    Code:
    graph pie, over(relevance) pie(_all, explode) plabel(_all percent, size(tiny)) ///
    by(, title("Relevance")) by(experience)
    I'm aware that sort is not a valid by option. Is there an option that would allow me to sort the graphs in descending (or ascending) order occurring to experience?

  • #2
    I would have to work hard even to have a rough idea of what that looks like. You should be able to show a sample graph and ideally to show example data. FAQ Advice #12 applies as always,

    Furthermore, are you under instruction to draw these graphs or are you open to discussion about other ways to present the data? I have to feel close to Edward Tufte who asserted that the only thing worse than a pie chart was a series of pie charts. (I trust that he really can imagine worse things.)

    Comment


    • #3
      Apologies for a lack of graph. While I am open to presenting the data through bar charts instead of pie charts, I will post the solution that I found.

      The WorkExperience variable by which I was graphing relevance was not sorted. To solve this problem, I labeled experience, then encoded WorkExperience and generated a variable called experience:

      Code:
      label define experience 6 "<5" 5 "6-10" 4 "11-15" 3 "16-20" 2 "21-25" 1 "25+"
      encode WorkExperience, gen(experience)
      After that, this code created graphs in the desired order:

      Code:
      graph pie, over(relevance) pie(_all, explode) plabel(_all percent, size(tiny)) ///
      by(, title("Relevance")) by(experience)

      Of course, these are the perhaps undesirable pie graphs. I will leave them here as they pertain to the original post, but I will strongly consider moving forward with something more logical, like bar graphs.
      Attached Files

      Comment


      • #4
        I think this would be much clearer as a bar chart. See e.g. https://www.statalist.org/forums/for...updated-on-ssc

        4 rows, 6 columns.

        See also https://www.stata-journal.com/articl...article=gr0066 which should be open to all by now. I will chase up with the Stata Journal staff.

        Comment

        Working...
        X