Announcement

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

  • Removing 0 values from stacked bar chart.

    Hi,

    I'm generating a stacked bar chart using the code below. I would like to remove labels with 0 values from the bar.

    Code:
    * -- Stacked bar chart --.
    graph bar variables*, ///
        over(laname, sort(1) descending label(labsize(vsmall) angle(90))) ///
        bar(6, bcolor(gray)) ///
        lines(lwidth(thin) lpattern(solid)) ///
        ytitle("% ", size(small) margin(vsmall)) ///
        ylabel(, labsize(vsmall) angle(horizontal) ) ///
        plotregion(lstyle(none)) ///
        lines(lwidth(vthin)) ///
        title("Title", size(medsmall) position(12) margin(vsmall)) ///
        subtitle("{it: Geo}", size(small) position(12)) ///
        caption("{it: Data source: Source}", ///
        size(vsmall)) ///
        note("Note.", size(vsmall)) ///
        stack percent ///
        legend(order( 1 "1" 2 "2" ///
            3 "3" 4 "4" ///
            5 "5" 6 "6") ///
        rows(2) cols(3)  size(vsmall) ///
        position(6) rowgap(.5) region(fcolor(white) lcolor(black))) ///
        blabel(bar, position(center) format(%9.0f) color(black) ///
        orientation(vertical) size(vsmall)) ///
        name(graph, replace)
    As a result, I'm getting the chart below:
    Attached Files
    Last edited by Konrad Zdeb; 16 May 2014, 09:38.
    Kind regards,
    Konrad
    Version: Stata/IC 13.1

  • #2
    Sounds like an if condition.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Sounds like an if condition.
      It crossed my mind, but I have six variables. Is my understanding correct that I will have to write it in a form var1 != 0 & var2 !=0 ?
      As a partial solution I coded 0 as missing values for that varlist. The graph looks fine but I don't like this solution as nothing is missing with respect to those variables.
      Last edited by Konrad Zdeb; 16 May 2014, 10:53. Reason: Comment
      Kind regards,
      Konrad
      Version: Stata/IC 13.1

      Comment


      • #4
        On second thoughts, my first idea won't work and my alternative is your alternative. I don't see the objection. You want no labels, so...

        Comment

        Working...
        X