Dear all,
I graph emission data for ,say 30, countries. As colors are not enough to separate countries from each other, I want to use markers. I want each country to have a different symbol. Here is a small sample of my data:
Here is what I come up with:
and the result:

2 questions, please. First, I want to let Stata know the countries by using id but when I plot the graph I want to see country names instead of ids. A side way to do this is to encode the country as country1 and then "xtset country1 year" and then plot the graph, which works fine. But is there a way to show country names in the legend, even in the case of using the "xtset id year" command?
Secondly and more importantly, when I have 20 countries, do I have to type starting from plot1opts(ms(Oh)) to all the way to plot20opts(ms(-)) one by one to differentiate the markers? Is there not a short command to let these markers vary regardless of the number of countries?
I really appreciate any insights. Thanks much.
I graph emission data for ,say 30, countries. As colors are not enough to separate countries from each other, I want to use markers. I want each country to have a different symbol. Here is a small sample of my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str24 country int year double emission float id "Afghanistan" 1995 920.74704 1 "Afghanistan" 1996 939.65816 1 "Afghanistan" 1997 1029.1133 1 "Afghanistan" 1998 1047.1674 1 "Afghanistan" 1999 880.55764 1 "Afghanistan" 2000 478.10435 1 "Afghanistan" 2001 418.2312 1 "Afghanistan" 2002 525.85404 1 "Afghanistan" 2003 588.07605 1 "Antigua" 1995 12024.509 2 "Antigua" 1996 12438.551 2 "Antigua" 1997 12949.813 2 "Antigua" 1998 13666.697 2 "Antigua" 1999 14056.152 2 "Antigua" 2000 14064.74 2 "Antigua" 2001 14316.295 2 "Antigua" 2002 15270.916 2 "Antigua" 2003 15820.542 2 "Argentina" 1995 10573.171 3 "Argentina" 1996 10910.546 3 "Argentina" 1997 11604.96 3 "Argentina" 1998 11932.882 3 "Argentina" 1999 11586.602 3 "Argentina" 2000 11331.958 3 "Argentina" 2001 10690.723 3 "Argentina" 2002 9561.1764 3 "Argentina" 2003 10172.063 3 "Australia" 1995 22648.291 4 "Australia" 1996 23271.226 4 "Australia" 1997 24010.643 4 "Australia" 1998 24950.277 4 "Australia" 1999 25658.207 4 "Australia" 2000 25834.54 4 "Australia" 2001 26528.388 4 "Australia" 2002 27119.407 4 "Australia" 2003 27871.535 4 "Bahamas" 1995 17111.225 5 "Bahamas" 1996 16741.521 5 "Bahamas" 1997 16624.036 5 "Bahamas" 1998 16705.854 5 "Bahamas" 1999 18425.053 5 "Bahamas" 2000 19088.042 5 "Bahamas" 2001 18533.119 5 "Bahamas" 2002 18377.338 5 "Bahamas" 2003 18381.131 5 "Bahrain" 1995 16906.196 6 "Bahrain" 1996 16865.345 6 "Bahrain" 1997 16889.001 6 "Bahrain" 1998 17048.288 6 "Bahrain" 1999 18054.555 6 "Bahrain" 2000 18652.151 6 "Bahrain" 2001 19093.738 6 "Bahrain" 2002 18882.95 6 "Bahrain" 2003 19560.6 6 "Barbados" 1995 14020.479 7 "Barbados" 1996 14237.518 7 "Barbados" 1997 14539.566 7 "Barbados" 1998 15050.467 7 "Barbados" 1999 15537.087 7 "Barbados" 2000 16086 7 "Barbados" 2001 15497.756 7 "Barbados" 2002 15450.672 7 "Barbados" 2003 15707.709 7 "Belgium" 1995 21936.724 8 "Belgium" 1996 22093.781 8 "Belgium" 1997 22786.21 8 "Belgium" 1998 23163.219 8 "Belgium" 1999 23793.334 8 "Belgium" 2000 24661.914 8 "Belgium" 2001 24821.924 8 "Belgium" 2002 25105.985 8 "Belgium" 2003 25262.252 8 end
Code:
xtset id year xtline emission, overlay recast (connected) plot1opts(ms(Oh)) plot2opts(ms(Th)) plot3opts(ms(T)) plot4opts(ms(+)) plot5opts(ms(-))
2 questions, please. First, I want to let Stata know the countries by using id but when I plot the graph I want to see country names instead of ids. A side way to do this is to encode the country as country1 and then "xtset country1 year" and then plot the graph, which works fine. But is there a way to show country names in the legend, even in the case of using the "xtset id year" command?
Secondly and more importantly, when I have 20 countries, do I have to type starting from plot1opts(ms(Oh)) to all the way to plot20opts(ms(-)) one by one to differentiate the markers? Is there not a short command to let these markers vary regardless of the number of countries?
I really appreciate any insights. Thanks much.
Comment