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: dynamic graphs
From
Rodrigo Briceño <[email protected]>
To
[email protected]
Subject
Re: st: dynamic graphs
Date
Mon, 1 Oct 2012 10:34:20 -0600
Thanks Nick for your help. In your recommendation the second } where
it needs to be located?
after restore? or after graph export?
foreach i in 8 225 29 220 18 251 222 221 224 24 276{
preserve
keep if isin == `i'
#delimit ;
twoway (line sfid sem, clpattern(dash))
(line liq_an sem', yaxis(2)),
ytitle(SFID como % emision, size(medsmall) color(blue) margin(small) axis(1))
ytitle(LIQ_ANUAL, size(medsmall) color(blue) margin(small) axis(2))
ylabel(#10, labsize(medsmall)) xtitle(SEMANA, size(medsmall)
color(blue) margin(small))
xlabel(#15, labsize(medsmall)) title(`b`i'', size(medsmall));
#delimit cr
restore}
graph export "D:\data\g_`i'.wmf", replace
Thanks
2012/9/29 Nick Cox <[email protected]>:
> Try changing
>
> #delimit ;
>
> twoway (line sfid sem if isin==`i', clpattern(dash))
> (line liq_an sem if isin==`i', yaxis(2)),
> ytitle(SFID como % emision, size(medsmall) color(blue) margin(small) axis(1))
> ytitle(LIQ_ANUAL, size(medsmall) color(blue) margin(small) axis(2))
> ylabel(#10, labsize(medsmall)) xtitle(SEMANA, size(medsmall)
> color(blue) margin(small))
>
> xlabel(#15, labsize(medsmall)) title(`b`i'', size(medsmall));
> #delimit cr
>
> to
>
> preserve
> keep if isin == `i'
> #delimit ;
>
> twoway (line sfid sem, clpattern(dash))
> (line liq_an sem', yaxis(2)),
> ytitle(SFID como % emision, size(medsmall) color(blue) margin(small) axis(1))
> ytitle(LIQ_ANUAL, size(medsmall) color(blue) margin(small) axis(2))
> ylabel(#10, labsize(medsmall)) xtitle(SEMANA, size(medsmall)
> color(blue) margin(small))
>
> xlabel(#15, labsize(medsmall)) title(`b`i'', size(medsmall));
> #delimit cr
>
> restore
>
>
> On Fri, Sep 28, 2012 at 7:19 PM, Rodrigo Briceño <[email protected]> wrote:
>> Dear Stata List Experts. I wrote a code to be able to run a set of 11
>> graphs (liq_an on the Y axis, SFID on the second Y axis, weeks on the
>> X axis). The code works perfectly, however there is one small issue
>> that I would like to improve (I'm using Stata 11.2). When I run the
>> graphs, all of them have the same axis range (starting from week 1 and
>> finishing on week 260; note: week in my code is represented by SEM).
>> Is there a way that I can modify, maybe with the definition of a
>> local, the range to show on each graph? (Please note that my dates are
>> in the format day/month/year).
>>
>> More specifically: starting and ending weeks for each one of my graphs are:
>>
>> isin8 1 1242
>> isin18 1 685
>> isin24 1 554
>> isin29 185 1181
>> isin220 487 1242
>> isin221 589 1242
>> isin222 589 1242
>> isin224 1 1242
>> isin225 1 1242
>> isin251 1 596
>> isin276 718 1242
>>
>> MY CODE:
>>
>> gen liq_an=(liq/100)*52
>> label var liq_an "Liquidez Anual"
>>
>> local b8 "BCCR c'$'a10 7/2/2002 a 7/2/2012"
>> local b18 "BCCR bem 30/9/2004 a 30/9/2009"
>> local b24 "BCCR bem 25/3/2006 a 25/3/2009"
>> local b29 "BCCR bem 28/9/2006 a 28/9/2011"
>> local b220 "FPTG bpgc$ 18/9/2008 a 18/12/2017"
>> local b221 "FPTG bpgd$ 18/9/2008 a 18/12/2019"
>> local b222 "FPTG bpge$ 17/9/2008 a 17/6/2022"
>> local b224 "FTCB bft13 9/9/2004 a 9/9/2013"
>> local b225 "FTCB bft15 21/6/2005 a 21/12/2015"
>> local b251 "G tp$ 27/5/2004 a 27/5/2009"
>> local b276 "ICE bic1$ 17/11/2009 a 17/11/2021"
>>
>> foreach i in 8 225 29 220 18 251 222 221 224 24 276{
>>
>> #delimit ;
>>
>> twoway (line sfid sem if isin==`i', clpattern(dash))
>> (line liq_an sem if isin==`i', yaxis(2)),
>> ytitle(SFID como % emision, size(medsmall) color(blue) margin(small) axis(1))
>> ytitle(LIQ_ANUAL, size(medsmall) color(blue) margin(small) axis(2))
>> ylabel(#10, labsize(medsmall)) xtitle(SEMANA, size(medsmall)
>> color(blue) margin(small))
>>
>> xlabel(#15, labsize(medsmall)) title(`b`i'', size(medsmall));
>> #delimit cr
>>
>> graph export "D:\data\g_`i'.wmf", replace
>> }
>>
>
> *
> * 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/
--
Rodrigo Briceño
Economist
[email protected]
MSN: [email protected]
SKYPE: rbriceno1087
*
* 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/