Announcement

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

  • Controlling categorical axis labels on bar graph

    Hello! I'm struggling trying to alter how the x-axis looks on a bar graph. Since it behaves as a categorical, rather than a simple x-axis, there doesn't seem to be any way to change the scale and control which value labels appear and which don't. The result is a mess in my case as can be seen on the attached graph (x-axis represents age). Is there any way to skip some values or control the labels in any way?
    Last edited by Jerry Blume; 04 Feb 2015, 14:43.

  • #2
    Hi, Jerry,

    It would be helpful if you showed the commands you actually used.

    By the way, did you add "sort" on the x?

    Best,

    Marcos
    Best regards,

    Marcos

    Comment


    • #3
      I stacked each of the different options on y-scale as 5 separate dummy variables over age variable on X-scale. If there's an easier way to do this, I'd be happy to know. I didn't sort the data, but the results represent only a single country and the fluctuations are due to a small sample.

      Code:
      graph bar gay_* if agea<=85, over(agea, gap(0)) stack ///
           tit("Gay men and lesbians should be free to live their own life" ///
           "as they wish") ///
           note ("Source: ESS Round 6: European Social Survey Round 6 Data (2012)") ///
          bar(1, color("49 130 189")) bar(2, color("158 202 225")) ///
              bar(3, color("99 99 99")) bar(4, color("252 146 114")) ///
              bar(5, color("222 45 38")) ///
          legend(size(small) col(3) order(1 5 3 2 4) ///
          label(1 "Agree strongly") label(2 "Agree") ///
              label(3 "Neither") label(4 "Disagree") ///
              label(5 "Disagree strongly"))

      Comment


      • #4
        I'd recast as a twoway bar problem. graph bar has a built-in tendency to assume that all your categories mean something distinct and so should be labelled.

        Comment


        • #5
          same question, I wonder if the same cat axis options available with over can somehow be invoked without? Using box plot instead of bar make sense when you don't want to have to collapse etc to show variance. Thanks!!!

          edit: sorry I answered myself, you just use ascat yvaroptions ...posting here for other users' reference
          Last edited by Nazzarena; 28 Oct 2021, 08:50.

          Comment

          Working...
          X