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: additional lines in a plot


From   stef salvez <[email protected]>
To   [email protected]
Subject   Re: st: additional lines in a plot
Date   Sat, 9 Jun 2012 17:26:58 +0100

thank you Nick. Now it works perfectly!

Again many thanks!

On 6/9/12, Nick Cox <[email protected]> wrote:
> According to your example, -Austria- is a string variable. -summarize-
> is not illegal with a string variable but attempts to use r(min) and
> r(max) thereafter will be rewarded with missing values. Remarkably, or
> not, this doesn't bite you until your graph command. In terms of what
> you were doing before, you should use -dAustria-.
>
> Nick
>
> On Sat, Jun 9, 2012 at 3:24 PM, stef salvez <[email protected]>
> wrote:
>> Thank you for this Nick,
>>
>> I add to my initial code  what you proposed; that is,
>>
>> su Austria, meanonly
>>
>> local max = r(max)
>> local date = r(min)
>> local dates `date'
>>
>> while `date' < `max' {
>>         local date = `date' + 28
>>         local dates `dates' `date'
>> }
>>
>> and works perfectly.
>>
>>
>> I only get a warning sign when I then type
>>
>>
>> scatter Aus  dAustria,   xline(`dates', lstyle(grid)  lw(vvthin)
>> lcolor(gs12))
>>
>> invalid line argument, .
>> r(198);
>>
>> Do I miss something?
>>
>> On 6/9/12, Nick Cox <[email protected]> wrote:
>>> Various ways depending on your rule for which you want plotted.
>>>
>>> But here is one.
>>>
>>> su datevar, meanonly
>>>
>>> local max = r(max)
>>> local date = r(min)
>>> local dates `date'
>>>
>>> while `date' < `max' {
>>>           local date = `date' + 28
>>>           local dates `dates' `date'
>>> }
>>>
>>> ... xli(`dates', lstyle(grid)  lw(vvthin) lcolor(gs12))
>>>
>>> But judging from your example data this will just make a busy graph
>>> busier. I would think in terms of plotting
>>>
>>> (time since last date) vs (this date)
>>>
>>> to make the gaps more evident.
>>>
>>> Nick
>>>
>>> On Fri, Jun 8, 2012 at 10:29 PM, stef salvez <[email protected]>
>>> wrote:
>>>> But I do not know how to add these vertical lines every 28 dates. Some
>>>> help would be greatly appreciated. It is an advanced topic and you are
>>>> the right person to provide some information
>>>>
>>>> On 6/8/12, stef salvez <[email protected]> wrote:
>>>>> Thanks Nick.
>>>>>
>>>>> As you said I added xline() for one time point for Austria:
>>>>>
>>>>>
>>>>>   scatter Aus  dAustria, xsize(20) ysize(8) c(l l)  xline( 17922 )
>>>>> ||///
>>>>>  scatter Bel dBelgium , c(l l)    || ///
>>>>>  scatter Aus t10, ms(none) mla(dA2) mlabpos(910) || ///
>>>>>  scatter Bel t9 , ms(none) mla(dB2) mlabpos(910) ///
>>>>>  yla(9 "Belgium"  10 "Austria"    , ang(h)) ///
>>>>>  xla(`=mdy(10,5,2008)' `=mdy(1,1,2010)' `=mdy(1,1,2012)', format(%td))
>>>>> legend(off)
>>>>>
>>>>> and it worked. The only difficulty is that I have to insert manually
>>>>> all these numbers (like 17922) which are the numerical representation
>>>>> of the dates. IS there any quicker way to do that; as I have many
>>>>> countries and for each country I have a different a sequence of dates.
>>>>> One example would be sufficient for me to understand how to move on,
>>>>>
>>>>>
>>>>> thanks again
>>>>>
>>>>>
>>>>> On 6/8/12, Nick Cox <[email protected]> wrote:
>>>>>> -xaxis()- is an option, not a command, but of no help here. You want
>>>>>> -xline()-. See also the SJ Tip cited earlier today to you.
>>>>>>
>>>>>> Nick
>>>>>>
>>>>>> On Fri, Jun 8, 2012 at 6:30 PM, stef salvez <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>>  According to the dataset below i have observations every 28 days (4
>>>>>>> weeks)  but in some cases i have jumps ( 35 days-or 5 weeks- and 42
>>>>>>> days -or 6 weeks).
>>>>>>>
>>>>>>>  I would like to construct vertical gridlines   every 28 days so as
>>>>>>> to see easier the one- and/or two-week shifts. The solution mignt be
>>>>>>> the
>>>>>>>  -xaxis- command but i do not know exactly how to fit it to the code
>>>>>>> below
>>>>>>>
>>>>>>>
>>>>>>> clear all
>>>>>>> cd d:\
>>>>>>> input str8  (Austria           Belgium          )
>>>>>>>  "2/11/08"     "07/12/08"
>>>>>>> "30/11/08"          "04/01/09"
>>>>>>> "28/12/08"          "01/02/09"
>>>>>>> "25/01/09"          "01/03/09"
>>>>>>> "22/02/09"          "29/03/09"
>>>>>>> "22/03/09"          "26/04/09"
>>>>>>> "19/04/09"          "24/05/09"
>>>>>>> "17/05/09"          "21/06/09"
>>>>>>> "14/06/09"          "19/07/09"
>>>>>>> "12/07/09"          "16/08/09"
>>>>>>> "09/08/09"          "13/09/09"
>>>>>>> "06/09/09"          "11/10/09"
>>>>>>> "04/10/09"          "08/11/09"
>>>>>>> "01/11/09"          "06/12/09"
>>>>>>> "29/11/09"          "03/01/10"
>>>>>>> "27/12/09"          "31/01/10"
>>>>>>> "31/01/10"          "28/02/10"
>>>>>>> "28/02/10"          "28/03/10"
>>>>>>> "28/03/10"          "25/04/10"
>>>>>>> "25/04/10"          "23/05/10"
>>>>>>> "23/05/10"          "20/06/10"
>>>>>>> "20/06/10"          "18/07/10"
>>>>>>> "18/07/10"          "15/08/10"
>>>>>>> "15/08/10"          "12/09/10"
>>>>>>> "12/09/10"          "10/10/10"
>>>>>>> "10/10/10"          "07/11/10"
>>>>>>> "07/11/10"          "05/12/10"
>>>>>>> "05/12/10"          "02/01/11"
>>>>>>> "01/01/11"          "30/01/11"
>>>>>>> "30/01/11"          "27/02/11"
>>>>>>> "27/02/11"          "27/03/11"
>>>>>>> "27/03/11"          "24/04/11"
>>>>>>> "24/04/11"          "22/05/11"
>>>>>>> "22/05/11"          "19/06/11"
>>>>>>> "19/06/11"          "17/07/11"
>>>>>>> "17/07/11"          "14/08/11"
>>>>>>> "14/08/11"          "11/09/11"
>>>>>>> "11/09/11"          "09/10/11"
>>>>>>> "09/10/11"          "06/11/11"
>>>>>>>
>>>>>>> end
>>>>>>> gen dAustria = date(Austria, "DM20Y")
>>>>>>> gen dBelgium = date(Belgium, "DM20Y")
>>>>>>>
>>>>>>> gen dA2 = dAustria - dAustria[_n-1]
>>>>>>> gen dB2 = dBelgium - dBelgium[_n-1]
>>>>>>>  gen Aus= 10
>>>>>>> gen Bel = 9
>>>>>>> gen t10 = (dAustria + dAustria[_n-1]) / 2
>>>>>>> gen t9 = (dBelgium + dBelgium[_n-1]) / 2
>>>>>>>
>>>>>>>  scatter Aus  dAustria, xsize(20) ysize(8) c(l l)|| scatter Bel
>>>>>>> dBelgium , c(l l)    || //
>>>>>>> scatter Aus t10, ms(none) mla(dA2) mlabpos(910) || ///
>>>>>>> scatter Bel t9 , ms(none) mla(dB2) mlabpos(910)
>>>>>>>  yla(9 "Belgium"  10 "Austria"    , ang(h)) xla(, format(%td))
>>>>>>> legend(off)
>
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index