Jonah Davids
Jonah Davids

Reputation: 41

Sorting graphs numerically instead of alphabetically

I have created a graph in Stata and I want to sort the items numerically. I want the countries with the greatest subnational revenue to be at the top. (Canada would be at the top if sorted numerically.)

At the moment, I can only get the items to sort alphabetically. As you can see, Afghanistan is at the top

enter image description here

I've uploaded the graph file (.gph) to google drive here: https://drive.google.com/file/d/1DMlE30SsY-L6v8ulCE2OOiTEeZA00DKk/view?usp=sharing

Please take a look and let me know how I might sort my graph items numerically.

Upvotes: 0

Views: 954

Answers (1)

Wouter
Wouter

Reputation: 3271

sysuse auto, clear
keep in 45/60
separate price, by(foreign) veryshortlabel
graph hbar price0 price1, over(make, sort(price) descending) yvaroptions(relabel(1 "Domestic"  2"Foreign")) nofill

sort_example

Upvotes: 3

Related Questions