Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[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   <[email protected]>
To   <[email protected]>
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 <[email protected]>
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 <[email protected]>
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index