Dear all,
This is the first time I post something here so excuse me if I make mistakes in following the procedure.
I am using the user-written program lgraph from SSC (version 3.0.0) in STATA 16.1.
I have produced several graphs with the same lgraph codes, to show the time series of a variable in two groups (treated and control) before and after a treatment date (as in conventional difference-in-difference analysis to visually inspect parallel trends). The code works as expected in every graph, but in one of them the legend does not. Specifically, in this particular graph the legend displays the line segment of one of the two groups adjacent the label. Unfortunately, based on the FAQ, posting screenshot is not recommended, but I reckon I would have helped to quickly visualize the problem. I have tried upload the png as suggested but I got an error message that the extension was not correct.
In any case, I have tried to play around with the code and fix it but nothing seems to work. What really puzzles me is why the same exact code (pretty much copy and pasted) produces this problem just here.
The code is the following:
Which is exactly equal to the following:
But for some reason the first shows the segment line in the legend, while the second (along with many others) does not.
here is a reduce form of the database reduced_db.dta .
Given that this is quite an urgent issue at the moment I would highly appreciate any help.
This is the first time I post something here so excuse me if I make mistakes in following the procedure.
I am using the user-written program lgraph from SSC (version 3.0.0) in STATA 16.1.
I have produced several graphs with the same lgraph codes, to show the time series of a variable in two groups (treated and control) before and after a treatment date (as in conventional difference-in-difference analysis to visually inspect parallel trends). The code works as expected in every graph, but in one of them the legend does not. Specifically, in this particular graph the legend displays the line segment of one of the two groups adjacent the label. Unfortunately, based on the FAQ, posting screenshot is not recommended, but I reckon I would have helped to quickly visualize the problem. I have tried upload the png as suggested but I got an error message that the extension was not correct.
In any case, I have tried to play around with the code and fix it but nothing seems to work. What really puzzles me is why the same exact code (pretty much copy and pasted) produces this problem just here.
The code is the following:
Code:
preserve keep if NUTS2 == "Veneto" | NUTS2 == "Lombardy" lgraph mrt date codice_regione /// if date>date("22oct2020","DMY") & date<date("22nov2020", "DMY"), minmax /// loptions(5 lcolor(navy); 3 lcolor(orange_red); 5 lpat(solid)) /// eoptions(5 lcolor(navy); 3 lcolor(orange_red); 5 lpat(solid)) /// nomarker tline(6nov2020, lcolor(black)) /// legend(on order( 5 "Veneto (blue)" 3 "Lombardy (orange)")) /// scale(1.2) ytitle("") /// xtitle("") graphregion(color(white)) /// xla(, format("%tddd-Mon")) /// ylab(, grid) ylab(,angle(0)) xlab(, grid) title(" A" ,justification(left)) restore
Which is exactly equal to the following:
preserve
keep if NUTS2 == "Campania" | NUTS2 == "Calabria"
lgraph mrt date codice_regione ///
if date>date("25oct2020","DMY") & date<date("15nov2020", "DMY"), minmax ///
loptions(15 lcolor(navy); 18 lcolor(orange_red); 15 lpat(solid)) ///
eoptions(15 lcolor(navy); 18 lcolor(orange_red); 15 lpat(solid)) ///
nomarker tline(6nov2020, lcolor(black)) ///
legend(on order(15 "Campania (blue)" 18 "Calabria (orange)")) ///
scale(1.2) ytitle("") ///
xtitle("") graphregion(color(white)) ///
xla(, format("%tddd-Mon")) ///
ylab(, grid) ylab(,angle(0)) xlab(, grid) title("B" ,justification(left))
restore
keep if NUTS2 == "Campania" | NUTS2 == "Calabria"
lgraph mrt date codice_regione ///
if date>date("25oct2020","DMY") & date<date("15nov2020", "DMY"), minmax ///
loptions(15 lcolor(navy); 18 lcolor(orange_red); 15 lpat(solid)) ///
eoptions(15 lcolor(navy); 18 lcolor(orange_red); 15 lpat(solid)) ///
nomarker tline(6nov2020, lcolor(black)) ///
legend(on order(15 "Campania (blue)" 18 "Calabria (orange)")) ///
scale(1.2) ytitle("") ///
xtitle("") graphregion(color(white)) ///
xla(, format("%tddd-Mon")) ///
ylab(, grid) ylab(,angle(0)) xlab(, grid) title("B" ,justification(left))
restore
here is a reduce form of the database reduced_db.dta .
Given that this is quite an urgent issue at the moment I would highly appreciate any help.