Statalist


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

Re: st: wrapping title with by option


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: wrapping title with by option
Date   Thu, 19 Jul 2007 23:00:28 -0400

Maarten--
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.

clear
sysuse auto
la def f 0 `""zero" "title""'  1 `""one" "title""'
la val for f
scatter pri mpg, by(for) subti("extra", suffix) name(by)
levelsof for, local(lev)
local g
foreach v of local lev {
scatter pri mpg if for==`v', ti(`: label (for) `v'') name(g`v')
local g `g' g`v'
}
gr combine `g', name(all)


On 7/19/07, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
I was trying to help these guys http://tables2graphs.com/doku.php by
providing them with Stata code for some of their graphs (they requested
that here:
http://www.stat.columbia.edu/~cook/movabletype/archives/2007/07/tables2graphsco.html
)

Anyhow I got already stuck on the first graph on what seems to be a
minor thing, the wrapping of the subtitles. I was trying to recreate
that graph with the -by()- option, but couldn't get the subtitles to
wrap.

The subtitles are obtained from the value labels, and titles wrap by
feeding them two (or more) strings, so thought lets create value labels
with multiple strings, which is possible by surrounding them with
compound quotes. However, for once I think that the compound quotes
work too well, because when I create the graph they are treated as one
string. I realize that this is good behaviour, but it doesn't solve my
problem of how to wrap titles with the -by()- option. Does anyone have
any thoughts?

*--------------- begin example ----------------
sysuse auto, clear

label defin foreign 0 `""realy long" "title""' /*
                */  1 `""another" "long title""'
label value foreign foreign
twoway scatter pri mpg, by(foreign)
*---------------- end example ------------------

Maarten
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index