Announcement

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

  • Coefplot how to change bar colors?

    My question is how can I change the bar colors when using

    HTML Code:
    coefplot
    I tried this:
    HTML Code:
      bar(1,bcolor(navy)) bar(2, bcolor(maroon))
    option bar() not allowed r(198);

    HTML Code:
    coefplot fcn1 fcn5, format(%9.0f) ///
    title("(a) Overall Perception of China", size(medium)) ///
    color(navy) lcolor(black) lpattern(solid) byopts(cols(1)) ///
    ciopts(recast(rcap)) citop citype(logit) ///    
    recast(bar) rescale(80) vertical  ///
    ytitle ("") ///
    graphregion(color()) yscale(r(0 50)) ylabel(0(10)50) ///
    addplot(scatter @b @at, ms(i) mlabel(@b) mlabpos(2) mlabcolor(black)) ///    
    xlabel(1 "Favourable" 2 "Neutral" 3 "Unfavourable") ///
    ylabel(, labcol(black)) barwidth(.3) legend(label(1 "Remainers") label(3 "Leavers") ring(0) position(2) bmargin(large)) 

  • #2
    coefplot is from SSC by Ben Jann. You don't provide a reproducible example, but here is one way using Ben's example from this link.


    Code:
    sysuse auto, clear
    regress price mpg trunk length if foreign==0
    estimates store D
    regress price mpg trunk length if foreign==1
    estimates store F
    coefplot (D, label(Domestic Cars)) (F, label(Foreign Cars))   ///
    , drop(_cons) xline(0) recast(bar) ciopts(recast(rcap)) ///
    citop barwidt(0.3) scheme(s1color)
    gr save gr1, replace
    
    coefplot (D, label(Domestic Cars) bcolor(red)) ///
    (F, label(Foreign Cars) bcolor(blue)), drop(_cons) xline(0) ///
    recast(bar) ciopts(recast(rcap)) citop barwidt(0.3) scheme(s1color)
    gr save gr2, replace
    
    gr combine gr1.gph gr2.gph, scheme(s1color)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	52.8 KB
ID:	1534490

    Comment

    Working...
    X