Announcement

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

  • Visualizing results: lollipop (or related) functionality in STATA?

    Hi everyone,

    I have data for different treatments and I would like to visualize the mean values for each of the treatments. The data is in % and the numbers are quite similar on a % scale (between 80-95). Using the regular graph figure looks extremely unpleasant as I essentially see a lot of irrelevant bar graph space. I would like to make it more visually appealing and came across a suggestion (for R) on using what they call "Lollipop figures", such as this one.

    I googled and was not able to find anything close to this in STATA. Any suggestions would be greatly appreciated. If such figures do not exist and cannot be added through additional addons, what feasible alternatives do I have other than bar graphs?


    Thank you!



  • #2
    See -graph dot- and -twoway dropline- for some examples. Here's a quick one:

    Code:
    sysuse auto, clear
    encode make, g(obs)
    twoway dropline mpg obs  , horizontal ylab(#72, value)
    (also, it's Stata, not STATA.)
    Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

    Comment


    • #3
      Thanks! The dropline command is definitely useful.
      If anyone has other suggestions as to how one could present the results even better, I'd be happy to learn.

      Comment


      • #4
        If your results cover a narrow range, the dropline subcommand is not likely to be the best way forward. Eric is bang on in recommending graph dot (and note its exclude0 option).

        Comment


        • #5
          Anyone with more (better) alternatives to visualize the above-described data?
          I'm concerned with cluttering and Moiré pattern​​​​​

          Comment


          • #6
            So how goes graph dot produce either problem?

            Comment


            • #7
              Sorry, it doesn't - I just missed your reply when writing my reply.
              However, personally, I find graph dot almost too simplistic but I like the exclude0 option. Does something like this also exist for other graph types? Have always been (unsuccessfully) looking for it.

              Comment


              • #8
                Originally posted by Peter Sommer View Post
                However, personally, I find graph dot almost too simplistic
                This is getting hard: You consider a twoway dropline too complex and a graph dot graph too simple. What could possibly be the intermediate graph between those two? Can you give us an example of the graph you are looking for?

                Originally posted by Peter Sommer View Post
                but I like the exclude0 option. Does something like this also exist for other graph types? Have always been (unsuccessfully) looking for it.
                Most graphs don't automatically include 0, so for most graphs that option would not make sense. It may be that the default axis labels include 0, though this is not forced to be true. If you don't like the default labels, then you can change the axis labels using the xlabel() or ylabel() options. For twoway dropline 0 is included by default as the dropline has to drop to something, and 0 is a reasonable default. If you want to change that, you can use the base() option.
                ---------------------------------
                Maarten L. Buis
                University of Konstanz
                Department of history and sociology
                box 40
                78457 Konstanz
                Germany
                http://www.maartenbuis.nl
                ---------------------------------

                Comment


                • #9
                  Originally posted by eric_a_booth View Post
                  See -graph dot- and -twoway dropline- for some examples. Here's a quick one:

                  Code:
                  sysuse auto, clear
                  encode make, g(obs)
                  twoway dropline mpg obs , horizontal ylab(#72, value)
                  (also, it's Stata, not STATA.)
                  Eric's code looks really good to me. To get it perhaps a bit closer to the example Peter offered, I'd recommend installing the 538 scheme (ssc install g538schemes, replace) and use scheme(538w).

                  The only thing I cannot seem to figure out is how to sort on mpg in descending order (?). Tried: sort(mpg), sort(mpg, descending), sort(mpg(descending), sort(descending(mpg)).

                  Any suggestions would be appreciated!


                  Attached Files

                  Comment


                  • #10
                    See also https://www.statalist.org/forums/for...mptoms-graphic -- updated today -- with by accident an example in which mpg decreases downwards from the top.

                    Comment


                    • #11
                      Originally posted by Nick Cox View Post
                      See also https://www.statalist.org/forums/for...mptoms-graphic -- updated today -- with by accident an example in which mpg decreases downwards from the top.
                      Thanks, Nick! That's a clever, (head-smackingly) simple solution. A "sort (varname, descending)" option would be ideal, but this will do just fine!

                      Comment


                      • #12
                        For another re-invention of lollipop charts, see #7 in https://www.statalist.org/forums/for...ailable-on-ssc

                        I am not sure that I see the point of these plots, unless it is to be a little different from a horizontal bar chart. That is, the purpose of a line is just the same as the purpose of a bar in a horizontal bar chart.
                        Last edited by Nick Cox; 04 Jan 2023, 03:42.

                        Comment

                        Working...
                        X