Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: line graphs + coloured areas between the lines


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: line graphs + coloured areas between the lines
Date   Thu, 5 Jul 2007 10:11:54 +0200

--- "Robert J�ckle" wrote:
> I have fitted a simple line graph with six lines 
> and I would like to colour the areas between the 
> lines. Additionally, I would like to fit labels 
> in the coloured areas if this is possible.

For color between the lines you can look at the 
-rarea- twoway graph. See the example below. For
labels in the colored areas you can look at the 
text option, see: -help added text options-

*------------------- begin example ------------
sysuse nlsw88, clear
recode age 46 = 45
gen byr = 1988 - age
gen lths = grade < 12 if grade < .
gen hs = grade == 12 if grade < .
gen sc = grade > 12 & grade < 16 if grade < .
gen com = grade >= 16 if grade < .
collapse (mean) lths hs sc com, by(byr)
gen zero = 0
gen tillhs = lths + hs
gen tillsc = tillhs + sc
gen one = 1

twoway rarea zero lths byr     ||         /*
   */  rarea lths tillhs byr   ||         /*
   */  rarea tillhs tillsc byr ||         /*
   */  rarea tillsc one byr,              /*
   */  xlab(1944(2)1954)                  /*
   */  xscale(range(1943 1954))           /*
   */  xtitle("year of birth")            /*
   */  ytitle("proportion")               /*
   */  title("distribution of education") /*
   */  plotr(m(zero))                     /*
   */  legend(order(4 3 2 1)              /*
   */         label(1 "less then"         /*
              */      "high school"  )    /*
   */         label(2 "high school"  )    /*
   */         label(3 "some college" )    /*
   */         label(4 "college"           /*
              */      "or more"      )    /*
   */  )
*----------------- end example ------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index