Statalist


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

Re: st: weighted scatter / different label size


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: weighted scatter / different label size
Date   Fri, 19 Oct 2007 16:09:54 +0100 (BST)

--- Philipp Rehm <philipp.rehm@gmx.de> wrote:
> I would like to produce a scatter plot in which the labels are 
> "weighted", i.e. are proportional to the size of what they indicate.

You can control the size of a label using the -mlabsize()- option, and
you can use that to make the kind of graph you want. See the example
below. Problem with these graphs is that the labels pretty soon become
illegible due to small size or overplotting.  

*------------- begin example ---------------
sysuse auto, clear
egen labcat = cut(pri), group(10)
qui centile pri
local median = r(c_1)
forvalues i = 0 / 9 {
	qui centile pri if labcat == `i'
	local labsize`i' = sqrt(r(c_1)/`median')
}
twoway scatter mpg wei if labcat == 0,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize0') || /*
    */ scatter mpg wei if labcat == 1,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize1') || /*
    */ scatter mpg wei if labcat == 2,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize2') || /*
    */ scatter mpg wei if labcat == 3,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize3') || /*
    */ scatter mpg wei if labcat == 4,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize4') || /*
    */ scatter mpg wei if labcat == 5,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize5') || /*
    */ scatter mpg wei if labcat == 6,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize6') || /*
    */ scatter mpg wei if labcat == 7,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize7') || /*
    */ scatter mpg wei if labcat == 8,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize8') || /*
    */ scatter mpg wei if labcat == 9,           /*
            */ msymbol(i) mlabel(make)           /*
            */ mlabp(0) mlabsize(*`labsize9')    /*
            */ legend(off)
*------------------ end example ---------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
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/
-----------------------------------------


      ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ 
*
*   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