Hi everyone,
Currently, I am working with a panel data set with countries and annual data from 1970 onwards in which the main variable is ton-kilometers freight transported by road.
I would like to get a line graph (xtline for instance) in which the country that gets treatment (Poland, country_id=70) gets a different color, navy, and all the control countries are having the same gray color. I made a dummy variable "donor" which equals 1 if the country is part of the control group.
I have read a lot about creating graphs with different colors for groups, however the problem that I keep encountering is that I want to combine a graph of two different groups (first sorted by country and then by donor or not).
I was thinking about creating a graph with all the lines for road_tkm of the control countries first (all in a gray color) and combining it with a graph of the treatment country. However, I can't find the code for giving all the lines of the donor pool one/gray color (but still showing the individual trends).
Does someone know what I can do? The final legend should only contain a gray bar with "donor countries" and a navy one for "Poland".
Here is a sample of my data:
xtline road_tkm if donor==1, lc(gs7) overlay
This is the simple command I tried for the first graph, but somehow STATA does not understand why I want to use only one color for all the lines (what I can understand, haha).
Thank you in advance!
Currently, I am working with a panel data set with countries and annual data from 1970 onwards in which the main variable is ton-kilometers freight transported by road.
I would like to get a line graph (xtline for instance) in which the country that gets treatment (Poland, country_id=70) gets a different color, navy, and all the control countries are having the same gray color. I made a dummy variable "donor" which equals 1 if the country is part of the control group.
I have read a lot about creating graphs with different colors for groups, however the problem that I keep encountering is that I want to combine a graph of two different groups (first sorted by country and then by donor or not).
I was thinking about creating a graph with all the lines for road_tkm of the control countries first (all in a gray color) and combining it with a graph of the treatment country. However, I can't find the code for giving all the lines of the donor pool one/gray color (but still showing the individual trends).
Does someone know what I can do? The final legend should only contain a gray bar with "donor countries" and a navy one for "Poland".
Here is a sample of my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte country_id float donor double road_tkm 70 0 17930 70 0 44546 70 0 136490 70 0 45365 70 0 24549 70 0 36592 70 0 36577 70 0 15761 70 0 377778 70 0 75023 70 0 32596 70 0 159527 70 0 191484 70 0 63688 70 0 38448 70 0 218888 70 0 42601 70 0 40277 70 0 69542 70 0 119740 70 0 233310 70 0 34024 70 0 36779 70 0 44088 70 0 40744 70 0 28515 70 0 303560 70 0 36847 70 0 77228 70 0 348559 70 0 259708 70 0 85989 70 0 174223 70 0 214204 70 0 51200 70 0 273107 70 0 262860 70 0 39240 70 0 37340 70 0 70452 70 0 42335 70 0 21393 70 0 39641 70 0 35472 70 0 40293 70 0 395311 70 0 461582 70 0 37183 70 0 80318 70 0 110481 70 0 56513 6 1 146508.69995977 6 1 192453.589541 6 1 180106.67735693 6 1 160123.95377196 6 1 89198.667941911 6 1 89382.555090445 6 1 51603.792959022 6 1 207347.92052656 6 1 93438.219018693 6 1 125843.81520744 6 1 58115.430934599 6 1 209839.86417566 6 1 164194.685136 6 1 224152.10290141 6 1 186081.65153941 6 1 43022.430944004 6 1 108376.1883243 6 1 89107.403303688 6 1 216247.20344118 6 1 75749.030108977 6 1 133173.2753314 6 1 24808 6 1 33482.496367013 6 1 171860.5919496 6 1 81967.942407818 6 1 202152.21394323 6 1 70888.468661318 6 1 65793.907557193 6 1 202874.0275468 6 1 47642.92774081 6 1 26530 6 1 180754.90115588 6 1 204532.44421558 6 1 34639.63109173 6 1 118878.00796988 6 1 155094.31411296 6 1 92935.455291299 6 1 131638.94369203 6 1 76233.776958745 6 1 37417.069348727 6 1 30391.898404295 6 1 112713.58262185 6 1 42280.276987106 6 1 218903.20857613 6 1 139142.51983372 6 1 103624.40978427 6 1 63186.290615772 6 1 95937.290551047 6 1 199992.59777756 end
This is the simple command I tried for the first graph, but somehow STATA does not understand why I want to use only one color for all the lines (what I can understand, haha).
Thank you in advance!
Comment