Announcement

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

  • upside down bar graph

    Hi,

    Can someone please tell what code in STATA can I use to make this upside down bar chart. I could not find anything on it. Thank you!

    Attached Files

  • #2
    I don't know about STATA. In Stata here is some technique: labmask is from the Stata Journal. It's not essential, but you need an ordering variable with value labels, at least if you follow this route.

    Code:
    sysuse auto, clear
    set scheme s1color 
    keep if foreign
    gen price2 = -price
    sort price2
    gen obs = _n
    labmask obs, values(make)
    gen zero = 0
    twoway rbar price2 price obs, horizontal yla(1/22, noticks valuelabel ang(h)) ///
    ysc(reverse) bfc(eltgreen*0.1)  xla(none) xtitle("") ytitle("")               ///
    || scatter obs zero, ms(none) mla(price) mlabpos(0) mlabcolor(black)          ///
    subtitle(Prices (USD)) legend(off)
    Click image for larger version

Name:	upsidedown.png
Views:	1
Size:	44.3 KB
ID:	1494879


    I can't read what is in the bars, and in any case it's your job to explain if you want something beyond what is shown to be possible here.

    You can get the long way towards with graph hbar, but I still recommend using twoway.

    Code:
    graph hbar (asis) price2 price , over(make, sort(1) gap(*0.2)) stack yla(none) bar(1, blc(green) bfcolor(eltgreen*0.1)) bar(2, blc(green) bfcolor(eltgreen*0.1)) legend(off)

    Comment

    Working...
    X