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: graph bar, x-axis and dates

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: graph bar, x-axis and dates Date Thu, 21 Apr 2011 17:24:44 +0100

```This is just a standard example or -twoway bar- and/or -rbar-.

clear
set obs 360
gen date = 144 + _n
format date %tm_M_CY
gen nspecial = floor(1000 * runiform())
gen ngeneral = floor(1000 * runiform())
gen ntotal = nspecial + ngeneral
twoway bar nspecial date || rbar nspecial ntotal date, legend(order(1
"special" 2 "general")) xla(180(60)460, format(%tm_CY))

Special points:

The height of the highest bar will be the sum of the heights of the
bars it contains. You need to calculate that for yourself.

In your case, your counts need to be constructed as

egen nspecial = count(special), by(date)
egen ngeneral = count(general), by(date)

On Thu, Apr 21, 2011 at 4:57 PM, Ben Ammar <Ben-Ammar@gmx.de> wrote:
> Hi everyone,
>
> I've got a panel dataset, where I want show the developement of two different groups in the course of time which worked fine by the following command:
>
> graph bar (count) special general, over (date) stack percentage
>
> Unfortunately, since there are more than 30 years of monthly data, the x-axis is filled with dates that it can't be read anymore. Is there a way that the graph shows only years, preferably in 5 year steps?
> I know that this is a time series graph so there should be in fact also a command like tsrline to avoid my problem. However I couldn't find anything that creates a graph like the above mentioned (stacked percentage of both groups in each month). I also checked "A visual guide to stata graphics" by Michael Mitchell but I couldn't find anything about a similar graph.

*
*   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–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index