Announcement

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

  • Transparency in tw bar

    Hi All,

    I've come across a problem in Stata 17 which looks to me like a bug. I tried to set the transparency for a twoway bar with the color option, but it only affects one of the bars. Here is an MWE:

    Code:
    sysuse auto, clear
    bysort rep78: egen mpg_avg = mean(mpg)
    
    tw bar mpg_avg rep78, color(green)
    // all bars are affected
    tw bar mpg_avg rep78, color(%25)
    // only the first bar is affected
    tw bar mpg_avg rep78, fcolor(%25)
    // same problem
    tw bar mpg_avg rep78, fcolor(green) lcolor(black%25)
    // Outlines of all bars are affected
    The same problem arises using the fcolor option, but not for the lcolor option.

    Is that my mistake or a bug?

    All best.
    Last edited by Adam Ansel; 15 Mar 2022, 06:07.

  • #2
    It is not a bug. You have multiple bars at the same location. Try

    Code:
     
     tw bar mpg_avg rep78, color(%2)

    Comment


    • #3
      Here is one way to plot each bar just once.
      Code:
      egen tag = tag(rep78)  tw bar mpg_avg rep78 if tag

      Comment


      • #4
        Thank you very much!

        Comment

        Working...
        X