Hello,
Below is my Stata code to generate a bar chart created by Twoway command. As what you can see in the generated graph after running the code, it does not have any value.
I want to add values to the graph like the attached snapshot.
Can someone help me with Stata code?
Thank you!
clear
input byte race outcome minor medium severe
1 1 .7048 .5184 .3047
2 1 .7004 .4876 .1779
3 1 .7232 .5578 .3354
4 1 .7284 .5508 .2053
1 2 .2429 .3565 .4077
2 2 .2461 .3705 .3543
3 2 .2297 .3363 .4086
4 2 .2258 .3401 .3744
1 3 .0522 .1251 .2875
2 3 .0535 .1419 .4687
3 3 .0471 .1059 .2561
4 3 .0457 .1091 .4204
end
// Set graph style
grstyle init
// Add race labels
label define race_label 1 ///
"Black" 2 "Hispanic" ///
3 "White" 4 "Other"
label values race race_label
// Add outcome labels
label define outcome_label 1 ///
"Low Disciplinary Action" ///
2 "Medium Disciplinary Action" ///
3 "High Disciplinary Action"
label values outcome outcome_label
g outcomerace = race if outcome == 1
replace outcomerace = race+5 if outcome == 2
replace outcomerace = race+10 if outcome == 3
sort outcomerace
list outcomerace outcome race, sepby(outcome)
set scheme s1color
// Minor Infractions Graph with symbols that show statistical significance.
tw (bar minor outcomerace if race==1, bcolor("27 133 255")) ///
(bar minor outcomerace if race==2, bcolor("213 17 89")) ///
(bar minor outcomerace if race==3, bcolor("1 191 127")) ///
(bar minor outcomerace if race==4, bcolor("255 212 1")), ///
legend(row(4) position(right) ///
order(1 "Hispanic" 2 "Black" 3 "White" 4 "Other") ) ///
legend(region(lstyle(none))) ///
xlabel(0(5) 15) ylabel(0(0.2) 0.8) ///
xlabel( 3 "Low" 8 "Medium" 13 "High", noticks) ///
ytitle("Predicted Probability of Disiciplinary Action") ///
title("Minor Infractions") xtitle("") ///
plotregion(style(none))
Below is my Stata code to generate a bar chart created by Twoway command. As what you can see in the generated graph after running the code, it does not have any value.
I want to add values to the graph like the attached snapshot.
Can someone help me with Stata code?
Thank you!
clear
input byte race outcome minor medium severe
1 1 .7048 .5184 .3047
2 1 .7004 .4876 .1779
3 1 .7232 .5578 .3354
4 1 .7284 .5508 .2053
1 2 .2429 .3565 .4077
2 2 .2461 .3705 .3543
3 2 .2297 .3363 .4086
4 2 .2258 .3401 .3744
1 3 .0522 .1251 .2875
2 3 .0535 .1419 .4687
3 3 .0471 .1059 .2561
4 3 .0457 .1091 .4204
end
// Set graph style
grstyle init
// Add race labels
label define race_label 1 ///
"Black" 2 "Hispanic" ///
3 "White" 4 "Other"
label values race race_label
// Add outcome labels
label define outcome_label 1 ///
"Low Disciplinary Action" ///
2 "Medium Disciplinary Action" ///
3 "High Disciplinary Action"
label values outcome outcome_label
g outcomerace = race if outcome == 1
replace outcomerace = race+5 if outcome == 2
replace outcomerace = race+10 if outcome == 3
sort outcomerace
list outcomerace outcome race, sepby(outcome)
set scheme s1color
// Minor Infractions Graph with symbols that show statistical significance.
tw (bar minor outcomerace if race==1, bcolor("27 133 255")) ///
(bar minor outcomerace if race==2, bcolor("213 17 89")) ///
(bar minor outcomerace if race==3, bcolor("1 191 127")) ///
(bar minor outcomerace if race==4, bcolor("255 212 1")), ///
legend(row(4) position(right) ///
order(1 "Hispanic" 2 "Black" 3 "White" 4 "Other") ) ///
legend(region(lstyle(none))) ///
xlabel(0(5) 15) ylabel(0(0.2) 0.8) ///
xlabel( 3 "Low" 8 "Medium" 13 "High", noticks) ///
ytitle("Predicted Probability of Disiciplinary Action") ///
title("Minor Infractions") xtitle("") ///
plotregion(style(none))
Comment