Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Creating complex legends?


From   "James Harris" <[email protected]>
To   <[email protected]>
Subject   st: Creating complex legends?
Date   Thu, 24 Jun 2004 16:39:40 +1000

I have set up a fairly complex graph: for each of two countries, it plots an estimated rate (FittedRate in the code below) with a shaded confidence interval bounded by the variables CIupRate and CIloRate. 

I would now like the legend entry for each country to include all the relevant parts of the twoway: ideally it would be a line (from elements 7 or 8 of the -twoway- statement below) with a background drawn from the corresponding -rarea-, bounded above and below by the -lines- in elements 3,5  or 4,6.  

At the moment I think I'll have to resort to adding these manually with a graphics editor - which I really don't want to do, as I have dozens of these charts. 

Is it possible to overlay these elements in the legend?

Many thanks

    James

(extract from do file follows)

		set scheme s1mono
		twoway ///
			rarea CIupRate CIloRate year if state=="NZ",  bcolor(gs14)  || ///
			rarea CIupRate CIloRate year if state=="OZ",  bcolor(gs12)  || ///
			line CIupRate year if state=="OZ",  clpattern(solid) clcolor(gs10)  || ///
			line CIloRate year if state=="OZ",  clpattern(solid) clcolor(gs10)  || ///
			line CIupRate year if state=="NZ",  clpattern(dash) clcolor(gs10)  || ///
			line CIloRate year if state=="NZ",  clpattern(dash) clcolor(gs10)  || ///
			line FittedRate year if state=="OZ", clpattern(solid) clcolor(gs1)   || ///
			line FittedRate year if state=="NZ", clpattern(dash) clcolor(gs1)  || ///
			, title("`gender'") 				///
			xtitle("Year", size(*1.5)) xscale(titlegap(*3))  ///
			legend( order(7 8) label(7 "Australia") label(8 "New Zealand") ) ///  
			ylabel(,angle(horizontal)) 			///
			xlabel (1988(2)2000) yscale(range(0 .)) 	///
			name(OZNZ`age'`gender', replace)  		// memory graphs
			



==========================================
 
James Harris
National Centre for Epidemiology and Population Health
Building 62
The Australian National University
CANBERRA ACT 0200 Australia
 
CRICOS Provider #00120C

*
*   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