Statalist


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

st: More subtle use of by-plots


From   Paul Seed <[email protected]>
To   [email protected]
Subject   st: More subtle use of by-plots
Date   Thu, 22 Nov 2007 16:36:26 +0000

"Vladimir V. Dashkeyev" <[email protected]>
and "David Elliott" <[email protected]>
have both recently asked questions relating to axes and arrows
when using overlaid graphs and bygraphs, to which various solutions have been offered.

I have been working with a related problem: to add text to one only of a series of by-graphs.
Any attempt to use titles or textboxes is replicated across all graphs.

The solution I eventually found was for each piece of text to first create an extra observation,
related to only one category, and then generate new variables containing the details to be revealed.
Then use �scatter- to plot invisible points with appropriate text.

clear
sysuse auto
local n = _N +1
set obs `n'
gen y1 = 35 in _N
gen x1 = 10000 in _N
gen star = "***" in _N

recode for . = 1

twoway ///
(scatter mpg price ) ///
(scatter y1 x1 , mlab(star) mlabsize(huge) ms(i) ) ///
, by(for)

This approach will also work for adding arrows, using -pcarrow-:

gen y2 = 20 if _n == _N
gen x2 = 8000 if _n == _N
twoway ///
(scatter mpg price ) ///
(pcarrow y1 x1 y2 x2 , ) ///
, by(for)


==========================
Paul T Seed MSc CStat
Senior Lecturer in Medical Statistics

King's College London
Division of Reproduction and Endocrinology

St Thomas' Hospital,
Lambeth Palace Road,
London SE1 7EH

tel (+44) (0) 20 7188 3642
fax (+44) (0) 20 7620 1227



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