Hi all,
I;m using Stata 13.1 and I am trying to generate a series of graphs whereby I highlight a specific (but different) bar in each graph. I have managed to get to the point of highlighting a specific graph, but I'm struggling to be able to add a label or some text above the highlighted bar. Just to take this further, I will highlight each bar in turn and wish the text to move according to which bar is highlighted. The text I wish to add is "your area"
*EXAMPLE CODE**
clear
set obs 21
g long name =.
replace name = _n
g area = name+10
gen mytext =""
levelsof name, local(levelstud)
qui foreach l of local levelstud {
replace mytext = "Your area" in `l'
}
forval i = 1/1 {
g y = `i'
**preserve
separate area, by(name == `i')
di `i'
g name2 = "your area" if name==`i'
graph bar area0 area1, nofill over(name, sort(area) axis(off)) yla("") legend(off) ///
bar(1, bfcolor(none)) plotregion(color(white)) blabel(name2, position(outside)) ytitle("")
**restore
}
I'm aware that in -blabel- 'name2' is not a names style. When I use just 'name' it adds a label to every single bar.
Any help appreciated
I;m using Stata 13.1 and I am trying to generate a series of graphs whereby I highlight a specific (but different) bar in each graph. I have managed to get to the point of highlighting a specific graph, but I'm struggling to be able to add a label or some text above the highlighted bar. Just to take this further, I will highlight each bar in turn and wish the text to move according to which bar is highlighted. The text I wish to add is "your area"
*EXAMPLE CODE**
clear
set obs 21
g long name =.
replace name = _n
g area = name+10
gen mytext =""
levelsof name, local(levelstud)
qui foreach l of local levelstud {
replace mytext = "Your area" in `l'
}
forval i = 1/1 {
g y = `i'
**preserve
separate area, by(name == `i')
di `i'
g name2 = "your area" if name==`i'
graph bar area0 area1, nofill over(name, sort(area) axis(off)) yla("") legend(off) ///
bar(1, bfcolor(none)) plotregion(color(white)) blabel(name2, position(outside)) ytitle("")
**restore
}
I'm aware that in -blabel- 'name2' is not a names style. When I use just 'name' it adds a label to every single bar.
Any help appreciated
Comment