Announcement

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

  • Legend in event_plot

    Dear community,

    I am trying to put a legend in position 7 of this graph, but it does give me a graph without any legend. Do you know what am I doing wrong?

    Code:
    # delimit ;
    event_plot event_twfe_02 event_twfe_04 event_twfe_06, 
        stub_lag(treated_Tp#) stub_lead(treated_Tm#) plottype(scatter) ciplottype(rcap) 
        together   
        graph_opt(title(" ") subtitle(" ") 
            xtitle(" ") ytitle(" ") 
            xscale(r(-1 1)) xlabel(-12(1)12, labsize(medium)) 
            yscale(r(-1 1)) ylabel(-200(50)10, nogrid labsize(medium) angle(2)) 
            graphregion(color(white)) bgcolor(white)
            yline(0, lcolor("190 190 190") lw(0.4)) 
            xline(-1, lcolor("214 39 40") lw(0.4) lp(dash))
            ysize(4) xsize(7)
            legend(order(1 "Men" 2 "Women" 3 "Men and Women")
                   region(lstyle(white)) position(8) size(medium) rowgap(0.5)) 
            )         
        lag_opt1(m(O) color("10 80 150")) lag_ci_opt1(color("30 100 180"))
        lag_opt2(m(S) color("10 110 10")) lag_ci_opt2(color("30 130 30"))
        lag_opt3(m(D) color("0 150 150")) lag_ci_opt3(color("30 180 180"))
        alpha(0.10) ;
    graph export "./event_study.pdf", replace ;
    # delimit cr
    This is the graph that the code produces:

    Click image for larger version

Name:	graph.png
Views:	1
Size:	58.7 KB
ID:	1763013

  • #2
    event_plot is from SSC, as you are asked to explain (FAQ Advice #12). . Perhaps legend(off) is in operation and you need legend(on) together with your other options to make progress.

    Running a trace should help you see the code used. Before you command

    Code:
    set trace on 
    set tracedepth 1
    where you may need to bump up the depth. You will see much code you don't care about but the last chunk is what may be revealing.

    I have never used event_plot and can't promise that is enough to get what you want.

    Comment


    • #3
      Thanks, Nick! It was the
      Code:
      legend(on)
      problem.

      Comment

      Working...
      X