Announcement

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

  • Can I turn off the "x-axis" on a bar chart?

    I'm attempting to remove the x-axis on a bar chart but I don't see an option for doing so in the help file. Here's my data and example. Note that my "x-axis", which Stata says doesn't exist on a bar chart, is actually the vertical axis since I'm making a horizontal bar chart.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str13(home away) float(pr_home pr_away pr_tie)
    "Aberdeen" "Kilmarnock" 59 15 26
    "Dundee United" "Motherwell" 26 43 31
    "Livingston" "Dundee" 46 24 30
    "Rangers" "Hibernian" 45 24 30
    "Falkirk" "Celtic" 19 52 28
    "Hearts" "St. Mirren" 82 4 13
    end
    
    
    graph hbar pr_home pr_tie pr_away, over(home, sort(1) descending label(nolabel)) stack ///
    ylabel(,nolabel nogrid noticks) yscale(lstyle(none))
    This is the minimal example. In reality, I'm making this version with more options, which I'll post below. I just want to get rid of the vertical axis. So if it's possible to at least control the color of it, I can change that to the background color (#252427) to make it disappear. Here is the actual full example:

    Code:
    graph hbar pr_home pr_tie pr_away, over(home, sort(1) descending label(nolabel)) stack ///
    bar(1, fcolor(#E8F8F4) lwidth(none)) bar(2, fcolor(#93E0D0) lwidth(none)) bar(3, fcolor(#2FAF95) lwidth(none)) ///
    legend( pos(6) row(1) color(white) order(1 "home" 2 "tie" 3 "away") ///
    region(color(#252427))) graphregion(color(#252427) margin(20 20 0 0)) plotregion(color(#252427)) ///
    ylabel(,nolabel nogrid noticks)  yscale(lstyle(none)) blabel(bar, position(center) format(%2.0f)) ///
    title("Week 17 Probabilities", color(white))

  • #2
    There is no "x-axis" in graph, only a categorical axis. You specify options for the categorical axis within -over()-.

    Code:
    graph hbar pr_home pr_tie pr_away, over(home, sort(1) descending label(nolabel) axis(off)) ///
    stack ylabel(,nolabel nogrid noticks) yscale(lstyle(none))

    Comment


    • #3
      Thank you Andrew! I did attempt to use that option but didn't think to put it inside of the over option.

      Comment

      Working...
      X