Announcement

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

  • graph box and graph box

    Dear Stata users,
    I have a continuous variable and I want to present the minimum value, maximum value, and average in a graph.

    I used graph box command to visualize it using box-plot. Since understanding of box-plot for readers of the report would be complicated, I have to visualize it using bar graph. Is there any way to create a bar-chart with three bars for minimum value, maximum value, and mean value of a continuous variable?

    below is the sample data using dataex command:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int monthly_income
     6000
     7000
     5000
    20000
    15000
    20000
     8000
    10000
     6000
     8000
    10000
     9000
     4000
     5000
     6000
    20000
    15000
     5000
     5000
     6000
     4000
     5500
     8000
    10000
    20000
    20000
    10000
    30000
    10000
     6000
     8000
     4000
     6000
     5000
     6000
     4000
     5000
     7000
     4000
     5000
     5000
    10000
     8000
    10000
    10000
    20000
     8000
    10000
    10000
     8000
    20000
    10000
    10000
     6000
     8000
    15000
     5000
    10000
     5000
     7000
     6000
     8000
     5000
     2000
     5000
     7000
     5000
    10000
     8000
     9000
     6000
     5000
    10000
    15000
    30000
    20000
    10000
    20000
    10000
     8000
    20000
    12000
     7000
    10000
    10000
    15000
    15000
    20000
     9000
    10000
    10000
     9000
    11000
    10000
    12000
    20000
     2000
    15000
    11000
    10000
    end
    Thanks in advance!

    Fahim


  • #2
    Certainly that's possible, as a minute looking at

    Code:
    help graph bar
    will show. Some variation on

    Code:
    graph bar (min) m (mean) m (max) m
    fits the specification, but it's too horrible to be worth showing or improving. Many other displays are possible that will do better. Here using stripplot (SSC) is a graph showing all the data (including several highly rounded values), so the minimum and maximum too, the median, 5% and 95% percentiles and the mean.

    Code:
    stripplot m, cumul cumprob box(barw(0.1)) pctile(5) refline vertical boffset(-0.2) aspect(1) yla(, ang(h))
    Click image for larger version

Name:	monthly_income.png
Views:	1
Size:	34.3 KB
ID:	1477559

    Comment


    • #3
      Dear Nick,
      Thank you a lot for kind help.

      stripplot is amazing!

      Comment

      Working...
      X