Announcement

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

  • Coefplot - color

    Dear all,




    I am using coefplot to display the coefficient estimates of one variable from different models in a single graph. However I can’t find a good solution to have all confidence intervals displayed in color navy.




    Here is my code:



    HTML Code:
    local y 20 40
    foreach x of local y {
        display "`x'"
        foreach outcome in "x2011" "x2012" "x2013" "x2014" "x2015" "x2016" {
        gen run`outcome'=run
    regress `outcome' run`outcome' c.x##c.y `covs' /*
    */, vce(cluster `cluster')
        
        local newlabel = substr("`outcome'", 2, .)
        label var run`outcome' "`newlabel'"
        estimates store est_`outcome'
    
    }
        
    coefplot (est_`outcome', keep(runx2011) mcolor(navy) levels(99 95 90)) /*
            */ (est_`outcome', keep(runx2012) mcolor(navy) levels(99 95 90)) /*
            */ (est_`outcome', keep(runx2013) mcolor(navy) levels(99 95 90)) /*
            */ (est_`outcome', keep(runx2014) mcolor(navy) levels(99 95 90)) /*
            */ (est_`outcome', keep(runx2015) mcolor(navy) levels(99 95 90)) /*
            */ (est_`outcome', keep(runx2016) mcolor(navy) levels(99 95 90)) /*
            */ , yline(0) graphregion(color(white)) bgcolor(white) legend(off) label vertical /*
            */ yscale(range(-0.01 0.03)) ymtick(-0.01(0.005)0.03) 
    }
    Click image for larger version

Name:	fop_coord_level_bw_20.png
Views:	1
Size:	74.5 KB
ID:	1527610

  • #2
    I don't think there is a way within -coefplot- , however, you can use the gen() option and the reconstruct the graph:

    Code:
    sysuse auto,clear
    
    regress price mpg headroom trunk length turn
    coefplot, drop(_cons) xline(0) keep(mpg) vertical levels(99 95 90) /// 
        gen(coef) name(gr1,replace)
    
    gen coefat90 = coefat - .025
    gen coefat99 = coefat  + .025
    
    scatter  coefb coefat, mc(navy) /// 
        || rcap coeful2 coefll2 coefat,  lc(navy) vertical /// 
        || rcap coeful1 coefll1  coefat90, lc(navy)  vertical  /// 
        || rcap coeful3 coefll3 coefat99, lc(navy) vertical /// 
        ||, xlabel(0 " " 1 "Milage" 2 " " ) yline(0) legend(off)

    Comment


    • #3
      for future reference:
      Code:
      ciopts(color(black))
      should do the trick

      Comment


      • #4
        Is it possible to use the economist colors in coefplot? Because it does not allow me to use e.g. eltblue " mcolor(eltblue) lcolor(eltblue) not allowed"


        OOOPS solved. It's all good.
        Last edited by Andrea Maier; 16 Nov 2022, 08:32.

        Comment

        Working...
        X