Statalist


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

st: Problem with a series of combined graphs


From   "David W. Harless" <[email protected]>
To   [email protected]
Subject   st: Problem with a series of combined graphs
Date   Fri, 25 Jan 2008 09:04:47 -0500

Dear Statalisters,

I am trying to make a series of combined graphs with
the identical layout.  But, in some circumstances,
one of the graph pairs being combined is irrelevant,
and I want to exclude the irrelevant graph but have
the relevant member of the pair appear with the
identical layout of other graphs in the series.

Here is an illustration using the auto data.

. sysuse auto.dta, clear
(1978 Automobile Data)

. table foreign rep78

----------------------------------------
          |      Repair Record 1978
 Car type |    1     2     3     4     5
----------+-----------------------------
 Domestic |    2     8    27     9     2
  Foreign |                3     9     9
----------------------------------------

As below, I want to make a series of combined graphs,
one for each of the five repair record ratings, with
one member of each pair showing Domestic vehicles and
the other member of the pair showing Foreign vehicles.

I use repair ratings 2 and 3 to illustrate:

forvalues i=2/3 {
    twoway scatter mpg weight if rep78==`i' & foreign==0, ///
        ylabel(0(10)50) xlabel(0(1000)5000) scheme(sj)  ///
        xtitle("") ytitle("") b1title("Domestic") ///
	saving(f0`i', replace)
    twoway scatter mpg weight if rep78==`i' & foreign==1, ///
        ylabel(0(10)50) xlabel(0(1000)5000) scheme(sj) ///
	xtitle("") ytitle("") b1title("Foreign") ///
        saving(f1`i', replace)
    graph combine f0`i'.gph f1`i'.gph, col(1) iscale(.8) xcommon ///
        title( "Figure `i'. mpg and weight when repair record is `i'", ///
        size(small) ) scheme(sj) ysize(8) xsize(6)
    /* graph export cg`i'.emf, replace */
}

The figure for repair rating 3 is exactly what I want.
The title and top half of the figure for repair rating 2
is also exactly what I want -- the identical font sizes,
plot region size, and so on as the other graph, but I want
the irrelevant bottom half excluded.

Of course, I've tried drawing only the relevant graph,
but despite trial and error with -ysize()- and -xsize()
and scaling individual parts of the graph, I haven't
been able to produce a graph with the identical layout
as the other combined graphs.

Is there a straightforward way to do this?

Dave Harless


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