Announcement

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

  • Bar graph colors

    Dear All,

    consider the following code and the corresponding output:

    Code:
    clear all
    sysuse auto
    graph hbar price, over(foreign) name(default) title("Default")
    graph hbar price, over(foreign) name(better) title("Better") intensity(*.2)
    graph hbar price, over(foreign) name(wanted) title("Wanted") bar(1, fcolor(maroon)) bar(2, fcolor(maroon)) 
    graph combine default better wanted, rows(1) xsize(16) ysize(9)
    I am puzzled why I can't write something like bar(*, fcolor(maroon)) or bar(_all, fcolor(maroon)). Is there a shortcut for not addressing each bar individually? (in my case the number of bars will vary, and I would like to avoid a loop, though this is clearly possible).

    I have consulted Mitchell's excellent book on Stata Graphics, but it only concluded that "Although we can use the bar() option to control the look of each bar, selecting a different scheme allows us to control the look of all the bars." I clearly don't want to change the scheme at all.

    Thank you, Sergiy Radyakin

    Click image for larger version

Name:	BarGraph.png
Views:	1
Size:	79.9 KB
ID:	1640166




  • #2
    I do not think that

    bar(2, fcolor(maroon))
    does anything. The default defines all bars as one. If you want to differentiate bars, the option is -asyvars-.

    Comment


    • #3
      The default defines all bars as one
      You are right as always.
      When I tried it now, it delivered the desired result with just the bar(1, fcolor(maroon)). Not sure what went wrong with my own experimentation with these options.

      If you want to differentiate bars, the option is -asyvars-.
      Thank you, I wish to change the color of the whole series at once.

      Thank you for advising! Solved it!

      Comment

      Working...
      X