stata - Why is x-axis in graph always alphabetical? How can I order x-axis according to my data? -


i have list of countries, gdp, , 2 variables employment

cntry gdppc ie_dummy fe_dummy 

data ordered alphabetically according cntry, first

gsort -gdppc 

sort descending gdp, highest lowest. when generate graph

graph bar ie_dummy fe_dummy, over(cntry) stack 

the x-axis country still alphabetically ordered, not reflecting order of data.

any ideas?

wherever idea originates (ms excel, maybe), lesson here don't sort elements of graph sorting data set itself. help graph bar points corresponding sort option, used within graphing command. simple example is:

clear set more off  sysuse educ99gdp  generate total = private + public  graph hbar (asis) public private, ///     over(country, sort(total) descending) stack ///     title( "spending on tertiary education % of gdp, 1999", span pos(11) ) ///     subtitle(" ") ///     note("source:  oecd, education @ glance 2002", span) 

in example, sorting done based on variable total, sum of public , private shares of spending on education.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -