Hello statalist.
I am trying to plot confidence intervals of some estimates calculated indexes from survey data on country level.
That is, I want a graph of lines showing each countries 95% confidence interval along with an indicator for the mean.
However, whenever I try to do so with my encoded iso3-code as the x-axis i get the results in the picture attached. I want an even space between the intervals, and most importantly I want the x-axis to not be a numerical representation, but either the country-name or the iso3 countrycode. For the life of me, I can't figure out, how to stop Stata from listing the countries as numerical values. My code is below:
egen lower_gini = pctile(indgini_year), by(iso3num year) p(2.5)
egen upper_gini = pctile(indgini_year), by(iso3num year) p(97.5)
egen mean_gini = mean(indgini_year), by(iso3num year)
twoway (scatter mean_gini iso3num if year == 2020, mcolor(red)) ///
(rcap lower_gini upper_gini iso3num if year == 2020, lcolor(red)), ///
legend(label(1 "2010") label(2 "2020")) ytitle("Perceived Gini coefficient") xtitle("Country")

Furthermore I have uploaded a picture of a representative example of what I am looking to create.
Thank you very much in advance!
I am trying to plot confidence intervals of some estimates calculated indexes from survey data on country level.
That is, I want a graph of lines showing each countries 95% confidence interval along with an indicator for the mean.
However, whenever I try to do so with my encoded iso3-code as the x-axis i get the results in the picture attached. I want an even space between the intervals, and most importantly I want the x-axis to not be a numerical representation, but either the country-name or the iso3 countrycode. For the life of me, I can't figure out, how to stop Stata from listing the countries as numerical values. My code is below:
egen lower_gini = pctile(indgini_year), by(iso3num year) p(2.5)
egen upper_gini = pctile(indgini_year), by(iso3num year) p(97.5)
egen mean_gini = mean(indgini_year), by(iso3num year)
twoway (scatter mean_gini iso3num if year == 2020, mcolor(red)) ///
(rcap lower_gini upper_gini iso3num if year == 2020, lcolor(red)), ///
legend(label(1 "2010") label(2 "2020")) ytitle("Perceived Gini coefficient") xtitle("Country")
Furthermore I have uploaded a picture of a representative example of what I am looking to create.
Thank you very much in advance!
Comment