I am new to Stata and I will be grateful if someone can help me figuring out how to add additional labels in my bar chart.
I have frequencies for 5 categories (let's say Apple, Orange, Banana, Grape, Lemon) and would like to make a bar chart comparing percentages of these categories (scale on Y is percentage) also would like to add frequency data outside of the bar as label.
However, I would like to incorporate more data associated with each category on the chart:
I have two indexes (CS and DS) calculated in Excel, values between 0 and 1 and between -1 and 0 respectively, so for each category I have two CS and DS indexes and I need to show them inside each bar for each category.
So:
var1 (categories): Apple, Orange, Banana, Grape, Lemon
var2 (frequencies): 65, 20, 1, 0, 39
var3 (CS index): 0.25, 0.12, 0, 0.42, 0.09
var4 (DS index): -0.15, -0.46, 0, -0.12, -0.2
It seems that I need to run a twoway
command but it failed.
I have used the code below to arrive roughly what I want to compare categories but I don't know how to add other data to that:
graph hbar (sum) var2, over(var1) blabel(bar, format(%9.3g)) asyvars
percentages showyvars bar(1, color(gs6)) bar(2, color(gs6)) bar(3,
color(gs6)) bar(4, color(gs6)) bar(5, color(gs6)) bar(6, color(gs6))
legend (off) bargap(100) ytitle("Percentage", size(3.5))
graphregion(fcolor(white)) plotregion(margin(zero))