Statalist The Stata Listserver


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

Re: st: RE: Graphs, pull out random values at peak interval


From   Knag Anne-Christine <[email protected]>
To   <[email protected]>
Subject   Re: st: RE: Graphs, pull out random values at peak interval
Date   Fri, 08 Jun 2007 10:02:52 +0200

By "this order" I meant the order that I have given
syntax:
generate order = 1 if type== "1C"
replace order = 2 if type== "1L"
replace order = 3 if type== "1M"
replace order = 4 if type == "1E"
replace order = 5 if type== "2C"
replace order = 6 if type== "2L"
replace order = 7 if type== "2M"
replace order = 8 if type== "2H"
replace order = 9 if type== "2E"

Since the graphs are ordered alphanumerically I need to add an "sort
according to order"-command somewhere in the syntax for the plots:

twoway (bar production day_of_prod), ytitle(Production) xtitle(Day of
production) by(type)

I also want to include a 10th plot showing the total production of all
types.

I hope this clarified my last question.
Thanks!
AC


On 6/7/07 3:07 PM, "Nick Cox" <[email protected]> wrote:

> This is too difficult for me to understand without
> knowing more about your data or what you mean by "this order".
> 
> My earlier solution was over-elaborate.
> 
> by group, sort : egen maxtime = max(time)
> by group : egen mintime = min(time)
> gen middletime = floor((mintime + maxtime) / 2)
> gen byte select = inrange(time, middletime - 12, middletime + 12)
> 
> can be slimmed to
> 
> by group (time), sort : gen middletime = floor((time[1] + time[_N]) / 2)
> gen byte select = inrange(time, middletime - 12, middletime + 12)
> 
> Nick 
> [email protected]
> 
> Knag Anne-Christine
>  
>> Thank you Mr Cox! I have another question regarding graphs. I
>> want to make
>> twoway bar graphs showing production of the different types
>> over a period of
>> time. I created the plots like this:
>> 
>>  twoway (bar production day_of_prod), ytitle(Production) xtitle(Day of
>> production) by(type)
>> 
>> I have ordered the type, how can I sort the plots in this order?
>> 
>> I tried to simply:
>> twoway (bar fec_div_div day_of_spawning), ytitle(Fecundity
>> *10-6) xtitle(Day
>> of spawning) by (treat, sort(order))
>> But this does not work..
>> 
>> I would also like to have a last summarizing showing total
>> production (all
>> types together). How can I add this in the syntax?
>> 
>  On 6/6/07 9:05 PM, "Nick Cox" <[email protected]> wrote:
>> 
>>> I don't see where the randomness enters in that
>>> case. Perhaps you just want 25 in the middle
>>> of each panel. 
>>> 
>>> In that case, there are numerous slight variations
>>> on this recipe:
>>> 
>>> by group, sort : egen maxtime = max(time)
>>> by group : egen mintime = min(time)
>>> gen middletime = floor((mintime + maxtime) / 2)
>>> gen byte select = inrange(time, middletime - 12, middletime + 12)
>>> 
>>> 
> 
> *
> *   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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index