Announcement

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

  • Is it possible to alternate bar graph labels so that they don't overlap?

    Greetings,

    I'm running Stata 15.1 on OSX. I'm trying to graph longitudinal data over three different over() variables (ideology, age group and year). This naturally entails a lot of bars and, consequently, a lot of overlapping value labels. I could reduce the size of the bar labels and/or increase the size of the graph (e.g. xsize(15)), but this would make them harder to read when pasted into a word document. I know you can alternate the y and x labels...is it possible to do the same with bar labels? If not, what's my best option here?.

    Here is my syntax:
    [CODE][graph bar W2MI if white==1 & W2MI!=. [pweight=weight], over(ideo3) over(age_cat) over(YEAR) asyvar blabel(total, format(%9.2f) size(medsmall)) bargap(30) xsize(12) ytitle("Percent") plotregion(fcolor(white)) graphregion(fcolor(white)) legend(col(1)) title("By Ideology")/CODE]

    And this is the graph it produces:

    Click image for larger version

Name:	W2MI.jpeg
Views:	1
Size:	258.7 KB
ID:	1448734


    Thanks in advance for your time!


  • #2
    Consider graph hbar or even tabplot (Stata Journal; https://www.statalist.org/forums/for...updated-on-ssc)

    If you post the data, people will be able to post alternative suggestions.

    collapse W2MI if white==1 [pweight=weight], by(ideo3 age_cat YEAR)
    dataex

    Comment


    • #3
      That's the one thing I forgot to include. Here it is:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(W2MI YEAR white) double ideo3 float age_cat
      . 1988 1 3 5
      . 1988 1 3 1
      . 1988 1 3 1
      . 1988 1 2 4
      . 1988 0 2 6
      . 1988 0 3 6
      . 1988 1 2 1
      . 1988 1 3 1
      . 1988 1 3 6
      . 1988 1 3 6
      . 1988 1 3 2
      . 1988 1 1 4
      . 1988 1 2 2
      . 1988 1 3 5
      . 1988 1 3 4
      . 1988 1 3 2
      . 1988 1 3 6
      . 1988 1 3 3
      . 1988 1 2 2
      . 1988 1 2 5
      . 1988 0 1 2
      . 1988 1 3 3
      . 1988 0 3 6
      . 1988 0 3 6
      . 1988 0 3 1
      . 1988 0 3 3
      . 1988 0 3 2
      . 1988 1 3 4
      . 1988 1 3 2
      . 1988 1 3 5
      . 1988 0 2 4
      . 1988 0 3 5
      . 1988 1 1 6
      . 1988 1 3 1
      . 1988 1 1 5
      . 1988 1 2 4
      . 1988 1 3 2
      . 1988 1 3 6
      . 1988 1 3 2
      . 1988 1 3 6
      . 1988 1 3 3
      . 1988 1 2 6
      . 1988 1 3 3
      . 1988 1 3 3
      . 1988 1 3 6
      . 1988 1 2 2
      . 1988 0 3 4
      . 1988 1 1 6
      . 1988 1 2 6
      . 1988 1 3 6
      . 1988 1 2 6
      . 1988 1 2 6
      . 1988 1 2 5
      . 1988 1 3 6
      . 1988 1 3 2
      . 1988 1 3 3
      . 1988 1 1 1
      . 1988 0 1 3
      . 1988 1 3 6
      . 1988 1 3 3
      . 1988 1 3 4
      . 1988 1 2 4
      . 1988 1 1 2
      . 1988 1 3 2
      . 1988 1 3 6
      . 1988 0 2 6
      . 1988 1 2 3
      . 1988 1 3 3
      . 1988 1 3 6
      . 1988 1 2 3
      . 1988 1 3 6
      . 1988 1 2 4
      . 1988 1 3 6
      . 1988 1 3 5
      . 1988 1 2 6
      . 1988 1 3 4
      . 1988 1 3 2
      . 1988 1 3 3
      . 1988 1 1 5
      . 1988 1 3 5
      . 1988 1 3 2
      . 1988 0 2 2
      . 1988 1 1 1
      . 1988 1 3 5
      . 1988 1 2 4
      . 1988 0 2 3
      . 1988 1 3 5
      . 1988 1 3 1
      . 1988 1 3 4
      . 1988 1 2 3
      . 1988 1 3 4
      . 1988 1 3 3
      . 1988 0 3 5
      . 1988 1 2 3
      . 1988 1 3 1
      . 1988 1 3 2
      . 1988 1 3 6
      . 1988 1 3 2
      . 1988 0 3 2
      . 1988 1 3 6
      end
      label values ideo3 ideo3
      label def ideo3 1 "Liberal", modify
      label def ideo3 2 "Moderate", modify
      label def ideo3 3 "Conservative", modify
      label values age_cat age_cat
      label def age_cat 1 "18-24", modify
      label def age_cat 2 "25-34", modify
      label def age_cat 3 "35-44", modify
      label def age_cat 4 "45-54", modify
      label def age_cat 5 "55-64", modify
      label def age_cat 6 "65+", modify

      Comment


      • #4
        Thanks for willingness, but that's not much use for illustration as all the responses are missing. I suggested precise code in #2 to get the 3 x 6 x 3 = 54 means shown in your example.

        Comment


        • #5
          I'm just wondering why not presenting the graph as a single column, I mean, each year would represent a row.
          Best regards,

          Marcos

          Comment

          Working...
          X