Announcement

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

  • RGB colors in twoway bar

    Dear all,

    I am trying to construct a -twoway bar-, in which the same RGB color should apply with different adjusted intensity to different bars. It turns out that all bars are affected and they are all filled with the exact same color.
    Here is a small example:
    Code:
    webuse auto, clear
    collapse (mean) price weight, by(foreign)
    gen x0 = foreign-.2
    gen x1 = foreign+.2
    *This graph with intensities of red works fine:
    tw bar price x0, barw(.4) base(0) fc(red) lc(gs0) || bar weight x1, barw(.4) fc(red*.5) lc(gs0) ylab(0(1000)6000) xlab(0 "Domestic" 1 "Foreign") legend(lab(1 "Price") lab(2 "Weight")) name(graphOK)
    *This one with intensities of an RGB color does not:
    tw bar price x0, barw(.4) base(0) fc("245 82 11") lc(gs0) || bar weight x1, barw(.4) fc("245 82 11"*.5) lc(gs0) ylab(0(1000)6000) xlab(0 "Domestic" 1 "Foreign") legend(lab(1 "Price") lab(2 "Weight")) name(graphNOTOK)
    Am a missing something with the quotes or anything else? Could someone provide a solution?
    Thanks very much.

    Sylvain

  • #2
    Hi Sylvain,

    the intensity specifier "*.5" has to got within the double quotes when specifying RGB colors (as decribed in section "Adjust intensity" of the help file):
    Code:
    webuse auto, clear
    collapse (mean) price weight, by(foreign)
    gen x0 = foreign-.2
    gen x1 = foreign+.2
    *This graph with intensities of red works fine:
    tw bar price x0, barw(.4) base(0) fc(red) lc(gs0) || bar weight x1, barw(.4) fc(red*.5) lc(gs0) ylab(0(1000)6000) xlab(0 "Domestic" 1 "Foreign") legend(lab(1 "Price") lab(2 "Weight")) name(graphOK)
    *This one with intensities of an RGB color does not:
    tw bar price x0, barw(.4) base(0) fc("245 82 11") lc(gs0) || bar weight x1, barw(.4) fc("245 82 11"*.5) lc(gs0) ylab(0(1000)6000) xlab(0 "Domestic" 1 "Foreign") legend(lab(1 "Price") lab(2 "Weight")) name(graphNOTOK)
    *...unless the intensity is specified via correct syntax:
    tw bar price x0, barw(.4) base(0) fc("245 82 11") lc(gs0) || bar weight x1, barw(.4) fc("245 82 11*.5") lc(gs0) ylab(0(1000)6000) xlab(0 "Domestic" 1 "Foreign") legend(lab(1 "Price") lab(2 "Weight")) name(graphNOWOK)
    Regards
    Bela

    Comment


    • #3
      Dear Bela,

      Of course you’re right...
      Thanks very much for spotting this so quickly!
      best,

      Sylvain

      Comment

      Working...
      X