Announcement

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

  • #16
    The vertical axis is not considered to be the y axis in graph bar or graph hbar or graph dot; it's a categorical axis.

    This is documented but here are some examples to get you going.

    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . graph hbar mpg, over(rep78)
    
    . graph hbar mpg, over(rep78, label(labsize(medlarge)))
    
    . graph hbar mpg, over(rep78, label(labsize(vlarge)))

    Comment


    • #17
      Hi Nick,

      I'm having a similar problem. I'm using catplot from SSC and trying to figure out how to change the size of the category axis labels. I tried using over, as you suggested above. Is this the right way to use it? It says that the data are not sorted. I've tried sorting on age and class together and separately, but can't figure it out. Here's my example code:

      Code:
      use titanic, clear
      
      catplot age class, name(G1a, replace) percent asyvars stack blabel(total, position(hbar) format(%3.1f) size(vsmall)) bar(1, color(forest_green)) bar(2, color(sandb)) ylabel(, labsize(small)) ytitle("Percent", size(small)) legend(size(vsmall)) over(class, label(labsize(small)))

      I'm also wondering if there is a way to only show the bar labels for bar 2 totals - i.e. the percentage of the stacked total?

      Thanks,

      Sonia


      Comment


      • #18
        Code:
        sysuse auto, clear
        
        catplot foreign rep78, percent asyvars stack blabel(total, position(hbar) format(%3.1f) size(vsmall)) bar(1, color(forest_green)) bar(2, color(sandb)) ylabel(, labsize(small)) ytitle("Percent", size(small)) legend(size(vsmall)) var1opts(label(labsize(small)))
        You can't get labels for only some bars, unless through editing This is a limitation of graph hbar. That's possible with twoway bar.

        Comment


        • #19
          Thanks Nick! That works for my example if I use var2opts rather than var1opts.

          Code:
           
           use titanic, clear  catplot age class, name(G1a, replace) percent asyvars stack blabel(total, position(hbar) format(%3.1f) size(vsmall)) bar(1, color(forest_green)) bar(2, color(sandb)) ylabel(, labsize(small)) ytitle("Percent", size(small)) legend(size(vsmall)) var2opts(label(labsize(small)))
          I'll try to see what I can do with twoway bar as well.

          Comment

          Working...
          X