Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# stacked area graphs [was: Re: st: staked area graph]

 From Nick Cox <[email protected]> To "[email protected]" <[email protected]> Subject stacked area graphs [was: Re: st: staked area graph] Date Wed, 19 Jun 2013 11:26:27 +0100

```-catplot- (SSC) is dedicated to (cross-classified) categorical data
and cannot help you much here, except that you could use the code to
work out how to get percents.

I don't gather from this precisely what is proving difficult for you,
but the main issue I would see as some preliminary data management to
get data in suitable form.

Here is a worked example:

webuse nlswork, clear
tab race
contract race year, zero
bysort year (race) : gen _percent = sum(_freq)
by year : replace _percent = 100 * _percent/_percent[_N]
reshape wide _percent _freq, i(year) j(race)
gen _percent0 = 0
levelsof year, local(years)

twoway rarea _percent0 _percent1 year || ///
rarea _percent1 _percent2 year || ///
rarea _percent2 _percent3 year, ///
legend(order(1 "white" 2 "black" 3 "other")) xla(`years')

Although people often want to produce such graphs, in practice they
are very difficult to get to work well. It is difficult to show the
smaller fractions, and especially _changes_ in the smaller fractions,
at all effectively. It is also difficult to get a legend to work well.
This example is one I would never want to use, except negatively.

-tabplot- from SSC is what I would use here.

Nick
[email protected]

On 19 June 2013 10:09, Marco Ercolani <[email protected]> wrote:
> [apologies, I meant: sta"c"ked area graph]
>
> Yes, I wish to illustrate the cumulated population proportions of disability types
> for a sub-population of disabled workers. Years are on the horizontal axis so I wish
> to see how these proportions evolve in time.
>
> To abstract from my own specific example;
> The user-written program -proprcspline- does a wonderful job of illustrating these
> proportions and placing labels in appropriate places. Unfortunately, for me, it also
> applies cubic spline smoothing. For example:
>
>  net install proprcspline.pkg
>  sysuse nlsw88, clear
>  proprcspline race industry, xlab(1(1)12)
>
>
> It seems that I am asking for something much simpler than what -proprcspline- does.
> If I were to generate these graphs myself I would do so by using the -collapse-
> command to generate population proportions and would then adapt the commands:
> www.survey-design.com.au/Stata Graphs.html in the plot labelled "// Area Plot" .
> (I seem unable to achieve this using the user-written program -catplot-)
>
*
*   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/
```