[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
[no subject]
>Nov 13, 2007 11:35 AM, Stephen P. Jenkins <[email protected]> wrote:
> I seek advice about how to set legend appearance in the case of
> multiply overlaid graphs.
<snip>
> Currently I can get it to
> appear twice for each group (once for the -connected- and once for the
> -scatter-) or not at all.
The legend order option -legend(order( ))- specifies which keys are to
appear:
-legend(order(1 2 3 4 5 6 7) region(lstyle(none))-
Scott
--------------------
Thanks to Scott for his recommendation, and to Philippe Van Kerm for
confirming that Scott's recommendation does what I wanted. (To be more
precise, the -legend- statement suggested is used an option to the
overall -twoway- command, and with no reference to -legend- in the
-scatter- subcommands, as I had in one of my alternatives.)
I have to admit that although I had read in -help legend_option- about
the -order- suboption, I had not understood from the text that it had
the functionality Scott refers to. To quote, "order(orderinfo) specifies
which keys are to appear in the legend and the order in which they are
to appear." I hadn't understood that, if the option is used, these are
the _only_ keys displayed.
Thanks also to Nick Cox, who sent me privately a number of alternative
and neat approaches to graphing the same information. His view is that
legends may add irritation as well as information. His proposed
alternative graphs hinge on labelling each of the series with a number,
either (i) placing the number to the RHS of each series, or (ii) using
the number itself as the marker symbol. I like the graphs a lot, though
I have to admit that I would still then want a legend to link identifier
with group.
I also learnt some new tricks for graphing commands from Nick that I
hadn't picked up before, and which would enable me to shorten my code.
See below, for Nick's alternatives based on the same data I sent to the
list earlier. Note e.g. the ability to have multiple arguments in
-msym()-, and the syntax in -mlabpos(0 ..)- . See -help stylelists-.
local yla -28.46 "6" -19.11 "3" -16.83 "7" -5.90 "1" 1.48 "0" 4.83 "4"
12.77 "2" 33.30 "5"
twoway connected pcch_eq0 pcch_eq1 point if point > 1, msym(O X) ||
///
connected pcch_eq2 pcch_eq4 pcch_eq5 point if point > 1, msym(D
d dh) lpattern(shortdash ..) || ///
connected pcch_eq3 pcch_eq6 pcch_eq7 point if point > 1, msym(T
t th) lpattern(dash ..) || ///
scatter pcch_eq? point if point == 1, msym(O X D T d dh t th)
///
xlabel(1/9, valuelabel) yaxis(1 2) yline(0) ymtick(-40(5)40,
axis(2)) legend(off) yla(`yla', axis(1) nogrid noticks ang(h)) ///
ytitle("Percentage change in income, wave t to t+1", axis(2))
forval i = 0/7 {
gen t`i' = `i'
}
twoway connected pcch_eq0 pcch_eq1 point if point > 1, ms(none ..)
mla(t0 t1) mlabpos(0 ..) || ///
connected pcch_eq2 pcch_eq4 pcch_eq5 point if point > 1, ms(none
..) mla(t2 t4 t5) mlabpos(0 ..) lpattern(shortdash ..) || ///
connected pcch_eq3 pcch_eq6 pcch_eq7 point if point > 1, ms(none
..) mla(t3 t6 t7) mlabpos(0 ..) lpattern(dash ..) || ///
scatter pcch_eq? point if point == 1, ms(none ..) mla(t0 t1 t2
t3 t4 t5 t6 t7) mlabpos(0 ..) ///
xlabel(1/9, valuelabel) yline(0, lw(thin)) ymtick(-40(5)40)
legend(off) ///
ytitle("Percentage change in income, wave t to t+1") yla(,
ang(h))
Stephen
-------------------------------------------------------------
Professor Stephen P. Jenkins <[email protected]>
Director, Institute for Social and Economic Research
University of Essex, Colchester CO4 3SQ, U.K.
Tel: +44 1206 873374. Fax: +44 1206 873151.
http://www.iser.essex.ac.uk
Survival Analysis using Stata:
http://www.iser.essex.ac.uk/teaching/degree/stephenj/ec968/
Downloadable papers and software: http://ideas.repec.org/e/pje7.html
Learn about the UK's new household panel survey, the United Kingdom
Household Longitudinal Study: http://www.iser.essex.ac.uk/ukhls/
Contribute to the consultation on content:
http://www.iser.essex.ac.uk/ukhls/consult/
*
* 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 |