Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Twoway scatter - legend options


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Twoway scatter - legend options
Date   Mon, 12 Aug 2013 17:11:35 +0100

You can do this various ways. Here's one:

gen long obsno = _n

forval j = 1/20 {
      su obsno if codreg == `j', meanonly
      local name = regione[r(min)]
      local call `call' `j' "`j' `name'"
}

... legend(order(`call')) ...

The idea is to look up the names given the numbers.

Nick
[email protected]


On 12 August 2013 16:51, Alice Guerra <[email protected]> wrote:
> Thanks Nick for your reply.
>
> The regions' names and the corresponding codes are organized as follows:
>
> regione codreg
>
> Abruzzo 13
> Basilicata 17
> Calabria 18
> Campania 15
> Emilia-Romagna 8
> Friuli-V.G. 6
> Lazio 12
> Liguria 7
> Lombardia 3
> Marche 11
> Molise 14
> Piemonte 1
> Puglia 16
> Sardegna 20
> Sicilia 19
> Toscana 9
> Trentino-A.A. 4
> Umbria 10
> Veneto 5
>
> Thanks for any help
>
> Alice Guerra
>
> On 12 August 2013 17:15, Nick Cox <[email protected]> wrote:
>> The first part is just a matter of using a different variable for
>> marker labels. The second part may be just a matter of building a
>> macro step by step that you feed to -legend(order())-.
>>
>> I could guess at details, but it's best that you tell us how you are
>> holding names "Abruzzo" etc and numbers 1..20 in your dataset.
>>
>> Nick
>> [email protected]
>>
>>
>> On 12 August 2013 16:03, Alice Guerra <[email protected]> wrote:
>>> Dear Statalists,
>>>
>>> I would like to plot a graph in which each Italian region is denoted
>>> by a number ("codreg" in the following code) instead of their own
>>> names. I would like then to insert in the legend the regions' names
>>> with the corresponding number. How can I modify the code to achieve
>>> this result?
>>>
>>> The code that I've used until now is as follows:
>>>
>>> twoway (scatter res0 load0m [aweight=pres0], msymbol(oh) mcolor(black)
>>> msize(large)) ///
>>> (scatter res0 load0m,  mlabel(codreg) msymbol(i) mlabcolor(black)
>>> mlabsize(vsmall) mlabpos(center)), ///
>>> ylabel(35(5)65, angle(0) labsize(small)) ytitle("tasso di
>>> risoluzione", size(small) height(5)) ///
>>> xlabel(0(500)1500, angle(0) labsize(small)) xtitle("casi definiti (in
>>> migliaia)", size(small) height(5))
>>>
>>> I am very grateful for any help and suggestion
>>>
>>> Kind Regards
>>>
>>> Alice Guerra
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index