Announcement

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

  • Setting barwidth and outergap in staked hbar

    I could not find a way to adjust width out the bar and "outergap" (the gap between the edge and the first and the last bar in hbar graph. Example is below. I believe I have specified "outergap" as per manual, but it does not change anything. Also, I do not know how to change the width of the bars.

    Thank you!

    use http://www.stata-press.com/data/r13/educ99gdp, clear

    graph hbar (asis) public private, over(country, sort(total) descending) stack ///
    outergap(.5) ///
    title( "Spending on tertiary education as % of GDP, 1999", span pos(11) ) subtitle(" ")

  • #2
    We ask for a reproducible example, as this better illustrates your problem and helps others who may have a similar problem in the future (refer to the FAQs) .

    I believe I have specified "outergap" as per manual, but it does not change anything.
    Not exactly, look at the manual again.

    Also, I do not know how to change the width of the bars.
    Use the option gap() within the over() option. Here is an example illustrating both.

    Code:
    sysuse auto
    *DEFAULT
    graph hbar (asis) headroom length if inrange(_n, 4, 10) , ///
    over(make, sort(total) descending) stack  bar(1, bcolor(blue%50)) ///
    bar(2, bcolor(blue%25)) scheme(s1color) 
    gr save g1
    
    *WITH OPTIONS
    graph hbar (asis) headroom length if inrange(_n, 4, 10) , ///
    over(make, sort(total) descending gap(30)) stack  bar(1, bcolor(blue%50)) ///
    bar(2, bcolor(blue%25)) scheme(s1color) outergap(*1.8)
    gr save g2
    
    *COMBINED
    gr combine g1.gph g2.gph, title( "Buick models: Comparison of headroom and length") scheme(s1color)


    Result:


    Click image for larger version

Name:	Graph.png
Views:	1
Size:	41.7 KB
ID:	1494612

    Comment

    Working...
    X