Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

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


From   <S.Jenkins@lse.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: -graph hbar- bars with colour used to identify groups of obs
Date   Thu, 7 Apr 2011 09:25:56 +0100

------------------------------

Date: Wed, 6 Apr 2011 10:58:06 -0400
From: Austin Nichols <austinnichols@gmail.com>
Subject: Re: st: -graph hbar- bars with colour used to identify groups
of obs

Stephen--

It's often easier to work in -twoway bar- for better control of graphs
e.g.

clear all
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"
lab def noctry 6 "EE" 7 "IE" 8 "EL" 9 "ES" 10 "FR", modify
lab def noctry 11 "IT" 12 "CY" 13 "LV" 14 "LT" 15 "LU", modify
lab def noctry 16 "HU" 17 "MT" 18 "NL" 19 "AT" 20 "PL", modify
lab def noctry 21 "PT" 22 "RO" 23 "SI" 24 "SK" 25 "FI", modify
lab def noctry 26 "SE" 27 "UK" 30 "IS" 31 "NO", modify
lab val noctry noctry
sort pp_all
g x=-_n
decode noctry, gen(lab)
labmask x, val(lab)
ren pp_all y
loc o , barw(.3) horiz leg(off) yla(-1/-21,val angle(0)) yti(" ")
tw bar y x if acc `o'||bar y x if !acc `o'

==========

Thanks for the additional tips, Austin.  Good to know there is more one
way to skin the cat.

As it happens, on this occasion, I preferred the look of the -graph
hbar- plot. Also, going that route with this relatively simple plot,
allowed me to avoid the -decode- and -labmask- stuff.  But I appreciate
that with more complicated structures that -graph twoway- is the way to
go.

(NB List readers who wish to run Austin's code without error should
change "acc" in the last line to "accession" if they have -set varabbrev
off- active.)


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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index