Different colour bars

Below is a worked example:

The commands I used in a do-file are:

clear

input ///
id w pos mark
1  1 1  69.55
2  1 2  65.16
3  1 3  64.91
4  1 4  64.53
5  1 5  63.70
6  0 6  84.58
7  0 7  84.51
8  0 8  84.12
9  0 9  83.34
10 0 10 82.8
end

label define kk        ///
1  "Barbora - CZE "    ///
2  "Christina - GER "  ///
3  "Linda - GER "      ///
4  "Sunette - RSA"     ///
5  "Huihui - CHN"      ///
6  "Keshorn - TRI "    ///
7  "Oleksandr - UKR "  ///
8  "Antti - FIN "      ///
9  "Vitezslav - CZE"   ///
10 "Tero - FIN"

label value pos kk

label define w 1 "Women" 0 "Men"
label value w w

graph bar (asis) mark,  over(id ) over(pos,label(angle(45))) over(w) ///
ylabel( 0(10)90, angle(45))                                         ///
blabel(bar, position(inside) format(%9.1f) color(black))            ///
scheme(s2color)  legend(off)                                        ///
bargap(5) title("London Olympics 2012" "Javelin")                   ///
nofill ytitle("Metres")                                             ///
bar(1, color(gold))      ///
bar(6, color(gold))      ///
bar(2, color(gs13))      ///
bar(7, color(gs13))      ///
bar(3, color(sienna))    ///
bar(8, color(sienna))    ///
bar(4, color(cyan))      ///
bar(9, color(cyan))      ///
bar(5, color(pink))      ///
bar(10, color(pink))

exit

To know more about Stata graphs, please have a look at the book Speaking Stata Graphics.

24 views

© 2020 by Survey Design and Analysis Services. 

  • LinkedIn
  • Facebook
  • Twitter
  • YouTube