In a time series line graph I have added two dashed vertical lines to delineate dates of interest using the tline command (in the example below I've made one grey, one orange). I would like to include these dashed lines to the legend so the graph is self-contained, rather than having to explain what they mean outside the graph.
I put together an example dataset to illustrate what I mean.
Here is the code for the graph:
I have searched Statalist, Stata help and several instructional videos and the answer to what I thought was a fairly simple question is remaining elusive.
Many thanks.
I put together an example dataset to illustrate what I mean.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float mdate long outcome float value 696 1 7 697 1 6 698 1 7 699 1 8 700 1 9 701 1 11 702 1 14 703 1 7 704 1 6 705 1 6 706 1 8 707 1 7 696 2 45 697 2 46 698 2 44 699 2 42 700 2 40 701 2 37 702 2 36 703 2 45 704 2 45 705 2 44 706 2 44 707 2 46 696 3 20 697 3 20 698 3 21 699 3 21 700 3 20 701 3 21 702 3 21 703 3 20 704 3 21 705 3 21 706 3 20 707 3 20 end format %tm mdate label values outcome outcomelbl label def outcomelbl 1 "var1", modify label def outcomelbl 2 "var2", modify label def outcomelbl 3 "var3", modify
Here is the code for the graph:
Code:
tsset outcome mdate twoway (tsline value if outcome==1) (tsline value if outcome==2) (tsline value if outcome==3), tline(2018m4, lp(dash) lc(grey) lw(thin)) tline(2018m8, lp(dash) lc(orange) lw(thin)) tlabel(#12) xlabel(, angle(45)) xlabel(, labsize(small))
Many thanks.

Comment