Announcement

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

  • Adjusting individual bar percentage labels with code?

    Hello!

    I'm wondering if there is any way to adjust individual bar percentage labels. For example, if I run the following code, how might I make the percentage for domestic white but the percentage for foreign black?

    Code:
    sysuse auto
    graph bar, over(foreign) /// 
    asyvars ///
    blabel(bar, pos(inside) format(%3.0f) size(medium) color(white))
    I tried the same strategy one would use for adjusting individual bar colors, e.g.:

    Code:
    graph bar, over(foreign) /// 
    asyvars ///
    blabel(1, pos(inside) format(%3.0f) size(medium) color(white))
    blabel(2, pos(inside) format(%3.0f) size(medium) color(black))
    But this didn't work, nor did a few other ideas. Any tips would be appreciated!

  • #2
    Yes, using the Graph Editor. It allows such modification.

    Code:
    sysuse auto,clear
    graph bar, over(foreign) /// 
    asyvars ///
    blabel(bar, pos(inside) format(%3.0f) size(medium) color(white))
    //From Graph Editor - modification to object specific properties
    gr_edit .plotregion1.barlabels[2].EditCustomStyle , j(-1) style(color(black))

    Comment


    • #3
      Hi Scott,

      Thanks a ton for this! I was hoping there was a way to do it within the -graph bar- options, but it sounds like it's only possible using Graph Editor code, yes?

      Also, I've never been successful at getting Graph Editor code to run--until now! Thank you so much!

      Comment

      Working...
      X