The following code, using a dataset that is shipped with Stata, combines
three graphs with individual titles and xtitles. Can you replicate the
problem using this dataset?
sysuse sp500, clear
replace volume = vol/10
gen month = month(date)
sort month
foreach v of varlist volume open close {
by month: egen lo_`v' = min(`v')
by month: egen hi_`v' = max(`v')
}
by month: keep if _n==_N
twoway rcap lo_v hi_v month || connect volume month, ///
title("LEGACY=0") xtitle("MAG1") ytitle("PARTIES") legend(off) ///
name(lo_legacy, replace) ylabel(,nogrid) xlabel(1(2)12) nodraw
twoway rcap lo_o hi_o month || connect open month , ///
title("LEGACY=4") xtitle("MAG2") legend(off) yscale(off) ///
name(med_legacy, replace) ylabel(,nogrid) xlabel(1(1)12) nodraw
twoway rcap lo_c hi_c month || connect close month , ///
title("LEGACY=8") xtitle("MAG3") legend(off) yscale(off) ///
name(hi_legacy, replace) ylabel(,nogrid) xlabel(1(1)12) nodraw
graph combine lo_legacy med_legacy hi_legacy, rows(1) ycom
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Guido Tiemann
> Sent: Wednesday, April 05, 2006 12:46 PM
> To: [email protected]
> Subject: st: Problem with "graph combine"
>
> Hi,
>
> I am actually having a problem when I try to produce a graph via "graph
> combine".
>
> My code:
>
> twoway (rcap lo00 hi00 distaxis) (scatter avg00 distaxis, connect(l)),
> title("LEGACY=0") xtitle("MAG1") ytitle("PARTIES") legend (off)
> name(lo_legacy) ylabel(,nogrid) ;
> twoway (rcap lo04 hi04 distaxis) (scatter avg04 distaxis, connect(l)),
> title("LEGACY=4") xtitle("MAG2") legend(off) yscale(off) name(med_legacy)
> ylabel(,nogrid) ;
> twoway (rcap lo08 hi08 distaxis) (scatter avg08 distaxis, connect(l)),
> title("LEGACY=8") xtitle("MAG3") legend(off) yscale(off) name(hi_legacy)
> ylabel(,nogrid) ;
> graph combine lo_legacy med_legacy hi_legacy, rows(1) ycom ;
>
>
> My problem:
>
> I am trying to combine three distinct scatterplots into a single one; the
> are supposed to have a common y axis and a separate x-axis for each
> subfigure. Unfortunately, using the code above I lose "title("LEGACY=8")"
> and "xtitle("MAG3")" in my third subfigure.
>
> So, did I commit some foolish error? Does anyone know a solution to this?
>
> Best regards,
>
> Guido Tiemann
>
>
*
* 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/