Announcement

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

  • Stacked Bar; multiple overs(); blabel()

    Hello list,

    I am aware this has been covered, I would just like discuss to bring this topic up to date.

    When using (1) graph bar stacked option with multiple overs(), in order to sort by multiple groups (<= 3), it has been made clear that (2) twoway rbar is inefficient in (or incapable of) creating this graphic in the same way as (1). The difference between the two is clear, and (1) is preferred to (2) for simplicity when using multiple overs(). I have only found one major lacking feature of (1), and that is the blabel() option. Has there been any progress in generating a blabel() feature to label total observations used? Or even better, a third external variable (e.g. "N")?

    So far the options are:

    1) Use graph editor and manually insert text (incredibly cumbersome and slow, especially when graphs are constantly evolving)
    2) twoway rbar which is much more involved, and potentially not even able to create the same desired outcome

    For completeness I'll include some code, but I believe it is clear without.

    e.g.

    #delimit ;
    graph bar ARRA_Spending Non_ARRA_Spending, over(PY) over(Program_Year, relabel(1 "Pre-ARRA" 2 "ARRA" 3 "Post-ARRA")) nofill stack
    ytitle("Funding Source (Mil. USD)")
    legend(label(1 "ARRA Expenditures") label(2 "Non-ARRA Expenditures"))
    blabel(bar, position(inside) format(%9.1f) color(white))
    blabel(TOTAL, position(outside) format(%9.1f));
    #delimit cr

    Where "TOTAL" would ideally be the total observations, count, or even a third variable "N".

    Thank you for your thoughts on this!

    - Bryan


  • #2
    As I commented in the earlier thread http://www.statalist.org/forums/foru...bars-per-year:

    do give us data we can use in a reproducible example and show the graph too.

    I have been using Stata graphics for 25 years but I can't read this command and instantly see precisely what kind of graph it would produce and understand what the issue is.

    http://www.statalist.org/forums/help#stata applies as always.

    Comment


    • #3
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(año pc pc_rural pc_urbe)
      2007 42.43301 74.01557 30.14837
      2008 37.3061 68.83646 25.375044
      2009 33.497147 66.71891 21.29751
      2010 30.77327 60.97694 20.008404
      2011 27.82427 56.06097 18.010962
      2012 25.81091 52.97845 16.647707
      2013 23.911655 47.96577 16.069237
      2014 22.727585 46.02896 15.331577
      2015 21.771584 45.18442 14.540774
      2016 20.742544 43.78548 13.86473
      2017 21.70001 44.37628 15.13522
      2018 20.488066 42.08461 14.422772
      end

      graph bar pc , over(año , label(labc("0 132 180"))) `opts' ///
      ylab(, labc("0 132 180")) blabel(total, c("29 202 255") format(%9.1f) ) ///
      ytitl("Porcentaje", c("0 132 180")) bar(1, c("0 172 237")) ///
      tit("Perú: Pobreza monetaria 2007 - 2018", c("0 132 180") span pos(11)) ///
      note("Fuente: ENAHO-INEI", c("192 222 237") span) ///
      graphregion(color(white))


      *Consulta: Para el siguiente gráfico ¿Como mantener la escala x: 2007 - 2018 y graficar solo una barra 2017?

      graph bar pc if año==2007, over(año , label(labc("0 132 180"))) `opts' ///
      ylab(, labc("0 132 180")) blabel(total, c("29 202 255") format(%9.1f) ) ///
      ytitl("Porcentaje", c("0 132 180")) bar(1, c("0 172 237")) ///
      tit("Perú: Pobreza monetaria 2007 - 2018", c("0 132 180") span pos(11)) ///
      note("Fuente: ENAHO-INEI", c("192 222 237") span) ///
      graphregion(color(white))

      Comment

      Working...
      X