I have a dataset concerning export dynamics over 61 countries from 1994-2014 with around 19 different variables. Additional I would like to investigate if certain natural events (e.g. flood, extreme temperature) influence the export dynamic. For the export dynamic I have for example the variable “TA1_c_y” which are the total exporting firms per country and year.
I graph the pattern of TA1_c_y over time. Additional, I would like to mark these years where a natural event happened. I am doing this by the option “xline”, where I insert different xlines with different colors to distinguish different types of natural events.
For the necessary information for the option xline I use the command “levelsof” to get the information which event happened in which country and at which time point. I save the results in a global macro $g1`m’, where 1 indicates the type of natural event and `m’ indicates the country. This all works fine.
When I plot the graph with the option “saving(titel, asis)” is see all xlines on the right position (picture 1), however, in the saved graph sometimes an additional line appears on a random places (outside on the left side of the graph picture 2). It seems so that the random line is not only one line but many overlaying lines.
Do you know, how to solve this problem or another option to mark the time points where a natural disaster happened? I use Stata15. My programming code is:
. forval i = 1/1 {
2. local label: var label A`i'
3.
. foreach m of numlist 6 {
4. local label_c: label(c_cat) `m'
5. twoway line TA`i'_c_y y if c_y_group==1 & c_cat==`m', ///
> sort(y) ///
> title(`label'_per_y_c_and_natdis) ///
> ylabel(,angle(0)) ///
> xline(0 ${g1`m'}, lcolor(maroon)) ///
> xline(0 ${g2`m'}, lcolor(brown)) ///
> xline(0 ${g3`m'}, lcolor(cyan)) ///
> xline(0 ${g4`m'}, lcolor(red)) ///
> xline(0 ${g5`m'}, lcolor(blue)) ///
> xline(0 ${g6`m'}, lcolor(yellow)) ///
> xline(0 ${g7`m'}, lcolor(green)) ///
> xline(0 ${g8`m'}, lcolor(black)) ///
> xline(0 ${g9`m'}, lcolor(ltblue)) ///
> xline(0 ${g10`m'}, lcolor(cranberry)) ///
> xline(0 ${g11`m'}, lcolor(orange)) ///
> name(g`i'`m', replace) ///
> saving(A`i'_per_y_c_and_natdis_country`m', asis replace)
6.
. }
7.
. }
file A1_per_y_c_and_natdis_country6.gph saved
Thanks!
Comment