I am trying to plot data on covid-19 cases by country. Here my data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 iso_code str32 country double total_cases_per_million str10 date_ float country_system "CHL" "Chile" 22102.186 "2020-09-06" 0 "CHL" "Chile" 10547.803 "2020-06-13" 0 "CHL" "Chile" 52489.801 "2021-04-01" 0 "CHL" "Chile" 21446.407 "2020-08-30" 0 "CHL" "Chile" 4857.396 "2020-05-26" 0 "CHL" "Chile" 23407.779 "2020-09-21" 0 "CHL" "Chile" 35244.959 "2021-01-18" 0 "CHL" "Chile" 28627.172 "2020-11-27" 0 "CHL" "Chile" 51499.96 "2021-03-29" 0 "CHL" "Chile" 45200.594 "2021-03-09" 0 "CHL" "Chile" 19079.254 "2020-08-05" 0 "CHL" "Chile" 33957.308 "2021-01-12" 0 "CHL" "Chile" 2059.509 "2020-05-13" 0 "CHL" "Chile" 227.817 "2020-04-04" 0 "CHL" "Chile" 27453.351 "2020-11-11" 0 "CHL" "Chile" 13552.059 "2020-06-25" 0 "CHL" "Chile" 30274.413 "2020-12-17" 0 "CHL" "Chile" 13118.03 "2020-06-23" 0 "CHL" "Chile" 4.603 "2020-03-14" 0 "CHL" "Chile" 30516.249 "2020-12-19" 0 "CHL" "Chile" 6749.246 "2020-06-01" 0 "CHL" "Chile" 18987.133 "2020-08-04" 0 "CHL" "Chile" .105 "2020-02-27" 0 "CHL" "Chile" 385.327 "2020-04-11" 0 "CHL" "Chile" 595.045 "2020-04-20" 0 "CHL" "Chile" 31302.964 "2020-12-26" 0 "CHL" "Chile" 17076.555 "2020-07-17" 0 "CHL" "Chile" 26604.177 "2020-10-30" 0 "CHL" "Chile" 47121.372 "2021-03-16" 0 "CHL" "Chile" 18494.043 "2020-07-30" 0 "CHL" "Chile" 15070.404 "2020-07-03" 0 "CHL" "Chile" 10910.741 "2020-06-14" 0 "CHL" "Chile" .68 "2020-03-07" 0 "CHL" "Chile" 27406.428 "2020-11-10" 0 "CHL" "Chile" 27861.382 "2020-11-16" 0 "CHL" "Chile" 36571.582 "2021-01-24" 0 "CHL" "Chile" 30096.396 "2020-12-15" 0 "CHL" "Chile" 27914.007 "2020-11-17" 0 "CHL" "Chile" 26898.743 "2020-11-03" 0 "CHL" "Chile" 25088.395 "2020-10-10" 0 "CHL" "Chile" 20902.052 "2020-08-24" 0 "CHL" "Chile" 14615.502 "2020-06-30" 0 "CHL" "Chile" 4650.033 "2020-05-25" 0 "CHL" "Chile" 1.308 "2020-03-10" 0 "CHL" "Chile" 1920.36 "2020-05-12" 0 "CHL" "Chile" 26005.732 "2020-10-22" 0 "CHL" "Chile" 866.49 "2020-04-29" 0 "CHL" "Chile" 42006.708 "2021-02-22" 0 "CHL" "Chile" 22260.742 "2020-09-08" 0 "CHL" "Chile" 36784.385 "2021-01-25" 0 "CHL" "Chile" 14884.803 "2020-07-02" 0 "CHL" "Chile" 35.938 "2020-03-22" 0 "CHL" "Chile" 437.116 "2020-04-14" 0 "CHL" "Chile" 36958.165 "2021-01-26" 0 "CHL" "Chile" 27117.824 "2020-11-06" 0 "CHL" "Chile" 5083.801 "2020-05-27" 0 "CHL" "Chile" 24677.801 "2020-10-05" 0 "CHL" "Chile" 44226.865 "2021-03-05" 0 "CHL" "Chile" 23742.574 "2020-09-25" 0 "CHL" "Chile" 24.116 "2020-03-20" 0 "CHL" "Chile" 689.153 "2020-04-24" 0 "CHL" "Chile" 29144.638 "2020-12-04" 0 "CHL" "Chile" 22633.463 "2020-09-12" 0 "CHL" "Chile" 25927.578 "2020-10-21" 0 "CHL" "Chile" 38233.941 "2021-02-01" 0 "CHL" "Chile" 41228.991 "2021-02-18" 0 "CHL" "Chile" 24759.407 "2020-10-06" 0 "CHL" "Chile" 17973.857 "2020-07-25" 0 "CHL" "Chile" .68 "2020-03-06" 0 "CHL" "Chile" 105.408 "2020-03-28" 0 "CHL" "Chile" 21787.845 "2020-09-03" 0 "CHL" "Chile" 27791.755 "2020-11-15" 0 "CHL" "Chile" 29806.171 "2020-12-12" 0 "CHL" "Chile" 9471.648 "2020-06-10" 0 "CHL" "Chile" 35839.062 "2021-01-21" 0 "CHL" "Chile" 300.269 "2020-04-08" 0 "CHL" "Chile" 19782.583 "2020-08-12" 0 end
Code:
xtline total_cases_per_million if country_system==1, i(country) t(date_) overlay title(Cumulative cases per million in federal countries) / / / scale(0.8) ytitle(Thousands cases per million) subtitle((in federal countries)) xtitle(date) / / / yla(0 "0" 20000 "20" 40000 "40" 60000 "60" 80000 "80" 100000 "100")
Array
I would like to modify the legend by deleting the "country=" part and by keeping only the name of the countries in order to have a better visualization. I tried to look in previous posts and in the documentation online but I am still struggling to solve it properly (namely in a quicker way than using the - order - command). Does someone know how to obtain this result?
Thank you in advance for anyone who is willing to help.
Best
Alessio Lombini
0 Response to How to get legend content equals the variable value
Post a Comment