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: RE: question on graphing a bar


From   Jian Zhang <jian32@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: question on graphing a bar
Date   Sat, 19 May 2012 12:47:57 +0800

Nick, now the bars look too big. Is there a way to reduce the width of the bars?

Jian

On Fri, May 18, 2012 at 10:47 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> The problem is trivial then. You just need to produce a dataset that is of the form exemplified in my first post. With three means, and nothing else explained, you could create that interactively.
>
> Also it is easy enough to automate that:
>
> gen means = .
> gen label = ""
> su non, meanonly
> replace label = "non" in 1
> replace means = r(mean) in 1
> su self, meanonly
> replace label = "self" in 2
> replace means = r(mean) in 2
> su wage, meanonly
> replace  label = "wage" in 3
> replace means = r(mean) in 3
>
> gen twothree = _n > 1
>
> graph bar (asis) means in 1/3 , over(label) over(twothree) asyvars stack
>
> Nick
> n.j.cox@durham.ac.uk
>
> Jian Zhang
>
> Each bar represents the mean of the variable in the sample.
>
> On Fri, May 18, 2012 at 10:35 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
>
>> If you don't ask the real question, you may not get the real answer.
>>
>> This still isn't clear to me: How is each variable going to produce one and only one bar?
>>
>> Nick
>> n.j.cox@durham.ac.uk
>>
>> Jian Zhang
>>
>> Nick, it works. but what  i have is a data set of three variables, say
>> non-earned income, wage_income and self-employment income. what i
>> wanted is a bar chart where there is one bar for non-earned income,
>> then one bar for wage_income and one bar for self-employment income
>> but the two later bars were stacked. Note that all the observations
>> have values for the three variables. So it is not possible to use the
>> option of over.  Is there a way to graph a bar like this with the
>> data?
>>
>> On Fri, May 18, 2012 at 10:05 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
>>> Consider
>>>
>>> clear
>>> set obs 3
>>> gen cat = _n
>>> gen twothree = _n > 1
>>> gen y = runiform()
>>> graph bar (asis) y , over(cat) over(twothree) asyvars stack
>>>
>>> Nick
>>> n.j.cox@durham.ac.uk
>>>
>>> Jian Zhang
>>>
>>> I was trying to graph a vertical bar chart where there are three bars.
>>> but i wanted the second and third bars stacked. Does anyone know how
>>> to do this? thanks!
>>>
>
> *
> *   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