Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Labelling the legend removes the legend count in spmap


From   Alex Olssen <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Labelling the legend removes the legend count in spmap
Date   Tue, 22 Dec 2009 11:22:51 +1300

Hi Scott,

Thanks very much!  That seems like exactly what I want.  I am in the middle of something right now but intend to try that out soon.

Alex

Alex Olssen
Intern
Motu Economic & Public Policy Research
Ph 939 4250  Fax 939 4251
This email contains information which is confidential and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this email or attachments. If you have received this in error, please notify us immediately by return email, facsimile or telephone and delete this email. Thank you


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Scott Merryman
Sent: Tuesday, 22 December 2009 9:56 a.m.
To: [email protected]
Subject: Re: st: Labelling the legend removes the legend count in spmap

On Mon, Dec 21, 2009 at 2:37 PM, Alex Olssen <[email protected]> wrote:
> Thanks Scott,
>
> I had kind of guessed at this.  The count of polygons is exactly what I want - as each polygon represent a very small but complete geographical unit.
>
> I am now wondering whether Stata stores the count number a scalar somewhere?  I have run several graphs and it would be far more efficient if I could make reference to a stored scalar in my code for the legend label as opposed to manually adding the count number to each label separately.
>
-spamp- does hold the counts in temporary matrix (`CLASS'), but I
believe you would have to rewrite how it labels the legend to work
with customized legend labels and the legend count.

What I have done in past is something like:

count if ratio >1 & ratio != . & xcoor != .
        local count6 = r(N)
count if ratio >.75 & ratio <=1  & xcoor != .
        local count5 = r(N)
count if ratio >.5 & ratio <=.75 & xcoor != .
        local count4 = r(N)
count if ratio >.25 & ratio <=.5 & xcoor != .
        local count3 = r(N)
count if ratio >0 & ratio <=.25 & xcoor != .
        local count2 = r(N)
count if ratio ==. & xcoor != .
        local count1 = r(N)

spmap ratio using "G:\data\us maps\usmap.dta", id(id)
clmethod(custom) clbreak(0 .25 .5 .75 1 10)  ///
        legend(label(6 "Greater than 1 (`count6') ")) ///
        legend(label(5 "0.75 to 1.00   (`count5') ")) ///
        legend(label(4 "0.50 to 0.75   (`count4') ")) ///
        legend(label(3 "0.25 to 0.50   (`count3') ")) ///
        legend(label(2 "0.00 to 0.25   (`count2') ")) ///
        legend(label(1 "No Data        (`count1') ")) ///
...

Scott

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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