| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: Bargraphs, order, SD
Hi, thank you. But how can I use a twoway when I am plotting just one
variable (e.g weight) of different types (1C, 1L etc)?
I tried the suggested syntax, but it came up with varlist: type: string
variable not allowed
?
AC
On 6/11/07 1:00 PM, "Nick Cox" <[email protected]> wrote:
> You need to move away from -graph bar- once you
> want to do something not obviously available.
>
> -twoway bar- is ultimately more flexible. Ulrich's
> example underlines this, so heed his advice.
>
> Here is a dopey example:
>
> u auto, clear
> egen mean = mean(mpg), by(foreign)
> egen sd = sd(mpg), by(foreign)
> gen upper = mean + sd
> gen lower = mean - sd
> twoway bar mean foreign, barw(0.4) || ///
> rcap upper lower foreign, xla(0 1, valuelabel) ///
> ysc(r(0, .)) legend(off) ///
> subtitle(mean +/- sd, place(w)) ytitle(`: var label mpg')
>
> Biologists in particular seems overly fond of just
> showing means (+/- sd, se, or constant * se) in what
> Stata user Paul Seed has called detonator plots.
>
> A dotplot with means and sds added (see -dotplot-)
> shows far more information.
>
> Nick
> [email protected]
>
> Knag Anne-Christine
>
>> Thank you Ulrich.
>> What do I then do if I want to make simple one-way bargraphs
>> by the same
>> order?
>> The syntax (without the order)
>>
>> graph bar (mean) variable1, over (type)
>>
>> And how can I add SD to the bars?
>
>> On 6/8/07 9:51 AM, "Ulrich Kohler" <[email protected]> wrote:
>>
>>> Knag Anne-Christine wrote:
>>>> 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.
>>>
>>> How about:
>>>
>>> ----------------------------------------------example.do
>>> label define order ///
>>> 1 "1C" 2 "1L" 3 "1M" 4 "1E" 5 "2C" ///
>>> 6 "2L" 7 "2M" 8 "2H" 9 "2E"
>>>
>>> encode type, gen(order) label(order)
>>>
>>> twoway ///
>>> || bar production day_of_prod ///
>>> || , ytitle(Production) xtitle(Day ofproduction) ///
>>> by(order, total)
>>> ---------------------------------------------------------
>
> *
> * 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/