Dear Stata users,
I am trying to plot an average with 1SD confidence intervals by unit in a panel data. I want the values to be sorted in the scatter plot by mean_var_perc in descending order from left to write, but the sort is not helping and the values in the chart are still sorted by id values. Sorting the data by mean_var_perc did not help either. Additionally, I want the id variable labels to be used as x axes label for each tick (so instead of id values i get the unit name; id variable does have appropriate value labels). The code I am using is below, could you please help me solve these problems?
I am trying to plot an average with 1SD confidence intervals by unit in a panel data. I want the values to be sorted in the scatter plot by mean_var_perc in descending order from left to write, but the sort is not helping and the values in the chart are still sorted by id values. Sorting the data by mean_var_perc did not help either. Additionally, I want the id variable labels to be used as x axes label for each tick (so instead of id values i get the unit name; id variable does have appropriate value labels). The code I am using is below, could you please help me solve these problems?
Code:
encode unit, generate(id) collapse (mean) mean_var_perc = var_perc (sd) sd_var_perc = var_perc, by(id) gen low=mean_var_perc - sd_var_perc gen hi=mean_var_perc + sd_var_perc twoway (rcap low hi id, sort(mean_var_perc)) /// (scatter mean_var_perc id, sort(mean_var_perc)), /// legend(off) ytitle("ytitle") xtitle("")
Comment