Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Eric Booth <ebooth@ppri.tamu.edu> |

To |
"<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: -graph hbar- bars with colour used to identify groups of obs |

Date |
Wed, 6 Apr 2011 14:38:01 +0000 |

<> Your bars look off-center because there are spaces for empty groups/bars. Add the nofill option. Here's some changes to your graph: **************! clear input noctry pp_all accession 1 9.019705 0 3 3.933862 1 6 13.28287 1 7 12.16459 0 9 10.973 0 11 11.85057 0 12 10.47666 1 13 12.20738 1 14 10.44716 1 15 8.407103 0 16 7.525132 1 18 5.768504 0 19 5.594264 0 20 10.31553 1 21 13.07521 0 23 7.804794 1 24 4.923772 1 25 6.715902 0 26 2.96161 0 27 8.402966 0 31 5.381824 0 end lab var noctry "Country" lab var accession "1: Accession country" label var pp_all "Rate (%)" lab def noctry /// 1 "BE" 2 "BG" 3 "CZ" 4 "DK" 5 "DE" /// 6 "EE" 7 "IE" 8 "EL" 9 "ES" 10 "FR" /// 11 "IT" 12 "CY" 13 "LV" 14 "LT" 15 "LU" /// 16 "HU" 17 "MT" 18 "NL" 19 "AT" 20 "PL" /// 21 "PT" 22 "RO" 23 "SI" 24 "SK" 25 "FI" /// 26 "SE" 27 "UK" 30 "IS" 31 "NO" lab val noctry noctry separate pp_all, by(accession) gr hbar pp_all0 pp_all1 , /// over(noctry, sort(pp_all) label(labsize(vsmall) labgap(4)) ) /// blabel(bar, format(%3.1f) ) /// scheme(s2mono) graphregion(color(white) ) /// bar(1, fcolor(gs10) ) bar(2, fcolor(black) ) /// legend(off) nofill ************************! - Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu Office: +979.845.6754 On Apr 6, 2011, at 9:25 AM, <S.Jenkins@lse.ac.uk> wrote: > I want to use -graph hbar- to show poverty rates across countries, where > the countries are ordered by poverty rate, and with the bars being one > colour for one country group, and another colour for the other country > group. I also want a black&white/shades-of-grey picture. > > Problem: I can draw the graph, but the bars are not centred over the > "slot" at each bar's base. For one group, they are left-justified within > the "slot"; for the other group they are right-justified. So, the graph > looks odd. See http://screencast.com/t/GIGwu99oy > > I've looked at the various options (including -asyvars-), and can't find > a fix. Below are the data and the code I've tried. > > Advice please. > > Data: > > noctry pp_all accession > 1 9.019705 0 > 3 3.933862 1 > 6 13.28287 1 > 7 12.16459 0 > 9 10.973 0 > 11 11.85057 0 > 12 10.47666 1 > 13 12.20738 1 > 14 10.44716 1 > 15 8.407103 0 > 16 7.525132 1 > 18 5.768504 0 > 19 5.594264 0 > 20 10.31553 1 > 21 13.07521 0 > 23 7.804794 1 > 24 4.923772 1 > 25 6.715902 0 > 26 2.96161 0 > 27 8.402966 0 > 31 5.381824 0 > > lab var noctry "Country" > lab var accession "1: Accession country" > label var pp_all "Rate (%)" > lab def noctry /// > 1 "BE" 2 "BG" 3 "CZ" 4 "DK" 5 "DE" /// > 6 "EE" 7 "IE" 8 "EL" 9 "ES" 10 "FR" /// > 11 "IT" 12 "CY" 13 "LV" 14 "LT" 15 "LU" /// > 16 "HU" 17 "MT" 18 "NL" 19 "AT" 20 "PL" /// > 21 "PT" 22 "RO" 23 "SI" 24 "SK" 25 "FI" /// > 26 "SE" 27 "UK" 30 "IS" 31 "NO" > lab val noctry noctry > > separate pp_all, by(accession) > > gr hbar pp_all0 pp_all1 , /// > over(noctry, sort(pp_all) ) /// > blabel(bar, format(%3.1f) ) /// > scheme(s2mono) graphregion(color(white) ) /// > bar(1, fcolor(gs10) ) bar(2, fcolor(black) ) /// > legend(off) > > > Stephen > ------------------ > Professor Stephen P. Jenkins <s.jenkins@lse.ac.uk> > Department of Social Policy and STICERD > London School of Economics and Political Science > Houghton Street, London WC2A 2AE, UK > Tel: +44(0)20 7955 6527 > Survival Analysis Using Stata: > http://www.iser.essex.ac.uk/survival-analysis > Downloadable papers and software: http://ideas.repec.org/e/pje7.html > > > Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: -graph hbar- bars with colour used to identify groups of obs***From:*Austin Nichols <austinnichols@gmail.com>

**References**:**st: -graph hbar- bars with colour used to identify groups of obs***From:*<S.Jenkins@lse.ac.uk>

- Prev by Date:
**Re: st: Xtmixed specification for rmANOVA with 2 within-subject factors** - Next by Date:
**Re: st: -graph hbar- bars with colour used to identify groups of obs** - Previous by thread:
**st: -graph hbar- bars with colour used to identify groups of obs** - Next by thread:
**Re: st: -graph hbar- bars with colour used to identify groups of obs** - Index(es):