Announcement

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

  • Paired bar graph

    Hi folks!

    New to Stata graphs, my current code is...
    Code:
    graph bar (mean) c_biology_fromF2 (mean) c_bmath_fromF2 (mean) c_chemistry_fromF2 (mean) c_civics_fromF2 (mean) c_english_fromF2 (mean) c_geography_fromF2 (mean) c_history_fromF2 (mean) c_kiswahili_fromF2, over(gender)
    However, I'd like to have sets of paired bars for each subject (biology, bmath, chemistry, etc.), one for males and one for females. Currently, there are two separate sets of bars for each subject. I'd like to reorganize the bars so each subjects' two bars (for M and F) are next to each other. Probably an easy thing, but I can't figure it out.

    Help much appreciated!

  • #2
    You show no graph and give no data, thus making the question tougher. It seems that drawing

    Code:
    graph bar (mean) c_biology_fromF2 (mean) c_bmath_fromF2 (mean) c_chemistry_fromF2 (mean) c_civics_fromF2 (mean) c_english_fromF2 (mean) c_geography_fromF2 (mean) c_history_fromF2 (mean) c_kiswahili_fromF2, over(gender)
    is just a complication on something like

    Code:
    graph bar (mean) y1 (mean) y2, over(x)
    from which a direct example that all can try such as

    Code:
    sysuse auto, clear
    graph bar (mean) turn (mean) trunk, over(foreign)
    would have been a much easier question.

    Please search the forum for mentions of statplot from SSC and then consider variants on

    Code:
    ssc inst statplot
    
    statplot turn trunk, over(foreign)
    statplot turn trunk, over(foreign) recast(bar)
    At the same time, dot charts are likely to be much less crowded than the bar chart with 16 bars that you're asking for, and that path is coded up too.

    Further, dot charts are likely to be much better at showing the real differences here. At a guess, differences between means for males and females are of the order of at most a few percent, and thus made harder to see by the convention of starting bars at zero:

    Code:
    statplot turn trunk, over(foreign) recast(dot) asyvars marker(1, ms(Oh) mcolor(blue)) marker(2, ms(+) mcolor(orange)) exclude0



    Last edited by Nick Cox; 11 Nov 2016, 03:50.

    Comment

    Working...
    X