Statalist


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

RE: st: wrapping title with by option


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   RE: st: wrapping title with by option
Date   Fri, 20 Jul 2007 10:41:42 +0200

--- Austin Nichols wrote:
> One option to add a second line is to use -subtitle("extra line",
> suffix)- but this is clearly not a general solution, since it adds the
> same second line to each graph. It seems that the -by()- option
> inevitably does not give one sufficient flexibility--but that option
> just automates the construction of multiple graphs that could also be
> produced separately and combined, so one general solution is to just
> do it manually. Note that -levelsof- and -foreach- are overkill here,
> but easier to extend to cases where there are more than two by-groups.

Austin, thanks for your reply. The reason I am trying to avoid 
-graph combine- is that almost never looks nice whenever the axis 
labels/titles aren't equally wide. In this case I am trying to 
reproduce this graph: 
http://tables2graphs.com/doku.php?id=03_descriptive_statistics#figure_1 ,
 so no y-labels in the second graph. You can tweak it by using the 
-fxsize()- option, but is quite fragile (you'll have to re-tweak the 
graph whenever you change the y-labels or whenever you use a 
different font). This is undesirable since this is intended as a 
code example that others might be able to use on their own data. The 
-by()- option automatically takes care of this problem, as can be 
seen in the example below. 

*--------- begin example --------
sysuse auto, clear
scatter pri mpg if for==0, /*
 */ name(dom, replace)
scatter pri mpg if for==1, /*
 */ name(for, replace)     /*
 */ ylab(none) ytitle("")

graph combine dom for,     /*
 */ ycommon xcommon        /*
 */ name("combined", replace)

scatter pri mpg, by(for)

*------- end example ------------

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