help stckar

stckar -- draws stacked area graphs

This package generates a stacked area graph of up to 10 variables. The variables are sorted by a summary statistic to improve the read- and comparability of the graph. It allows for (alternating) positive and negative variable values.

Syntax

stckar
varlist
[if]
[,
options]

where varlist is

y1 [y2 ... y10] x

Options

Option

nototal supresses the line plot of the total of all variables

nosort set input order of y-variables as the plotting order, starting on the highest layer

nolabels use variable names instead of variable labels for the legend

nodraw the standard nodraw option

order displays the plotting order

nofixedcolors deactivates the feature that the graph colors are fixed to the variable input order

statistics(stat) Defines which statistic of the summary command should be used for ordering the variables, variables with summary values closer to 0 are plotted closer to the x-axis.

scheme(scheme) use this option to set a specific scheme for the graph

graphoptions(options) accepts the standard twoway options for styling the graph

areaoptions(options) should accept the standard twoway options for the area graphs

lineoptions(options) accepts line options for the total line

Notes

By standard the command generates a legend with the variable labels, for variables without a label the variable name is used.

The legend entries can be overwritten by using graphoptions(options). As the command reorganizes the input order of the variables it is necessary to adjust the labeling order according to the order determined by the command.

Use the order option and then adjust the command accordingly.

The total line is always the last. Meaning that if you e.g. input 7 y-variables the option to modify the label of the total would be graphoptions(legend(label(8 label for total))).

Also the colors assigned to the variables are determined by the variable input order.

The implementation of this feature limits the use of scheme() in the graph/area/lineoptions(), as this will not change the variable colors unless you also use nofixedcolors.

While sorting is active (that is no use of nosort) the input order of y-variables is irrelevant in almost all cases and different input orders should lead to identical graphs.

The package utilizes the standard area command and calculates the correct sums.

The command was written with Stata 16.1.

Examples

Example 1 - some macroeconomic data

webuse klein2
stckar c i g year, lineoptions(lcolor(red)) graphoptions(legend(label(4 "y")))

Example 2 - change in prison population by length of prison term

use http://fmwww.bc.edu/ec-p/data/wooldridge/prison
collapse cag0_14 cag15_17 cag18_24 cag25_34, by(year)
stckar cag0_14 cag15_17 cag18_24 cag25_34 year

Author

Jonathan Thiele
jonathan.thiele@fu-berlin.de
written at the RWI - Leibniz-Institut fuer Wirtschaftsforschung