help streamplotstreamplot v1.82 (GitHub)

streamplot

: A Stata package for stream plots.

The command is based on the following guide on Medium: Stream plots.

Syntax

streamplot y x [if] [in], by(varname)
[ palette(str) smooth(num) labcond(str) offset(num) alpha(num) droplow yreverse cat(varname)
recenter(top|mid|bot) lcolor(str) lwidth(str) labsize(num) labcolor(color|palette)
percent format(str) area nolabel wrap(num) tline tlcolor(str) tlwidth(str)
tlpattern(str) yline(str) labprop labscale(num) wrap(num) *
]

The options are described as follows:

streamplot y x The command requires a numeric y variable and a numeric x variable. The x variable is usually a time variable.

by(var) This is the group variable that defines the layers.

cat(var) This is a binary variable that defines the split above and below the y=0 axis. Useful for comparise by() variables across two categories.
Note that defining cat() overwrites the recenter() option explained below.

recenter(top|mid|bot) This option changes where the graph is recentered. The default option is recenter(middle).
Additional options are recenter(top) or recenter(bottom).
For brevity, the following can be specified: middle = mid = m, top = t, bottom = bot = b.

yreverse Reverse the variable labels.

nolabel Hide the variable labels.

area Show stacked area graph. Options recenter(bottom) and smooth(0) are recommended with this option.

droplow If there are fewer than 10 observations per by() variable, the command will throw an error. If only some groups have this issue,
then use the droplow option to drop these observations. This option is intended to quickly plot the data. Ideally, clean up the data before plotting.

smooth(num) The smoothing parameter defined in terms of last observations to use. The default value is smooth(3).
A value of 0 implies no smoothing.

palette(str) Color name is any named scheme defined in the colorpalette package.
Default is tableau.

alpha(num) The transparency of area fills. The default value is alpha(100). It is better to leave this option as it is.

offset(num) Extends the x-axis range to accommodate labels. The default value is offset(15) for 15% of xmax-xmin of the axis range.

wrap(num) Wrap the labels after a number of characters. For example, wrap(50) will wrap labels every 50 characters.

labcolor(str) Label colors are either defined as a single color, e.g. default is labc(black). Or if labc(palette) is specified,
labels have the palette() colors.

labsize(str) Size of the stream labels. Default value is labs(1.4).

percent Shows the percentage share for the y-axis categories.

format() Format the values of the y-axis category. Default value is format(%12.0f).

xlabel() This is the standard twoway graph option for labeling and formatting the x-axis.

labcond(num) The label condition can be used to limit the number of labels shown.
For example, labcond(100) will only shows labels where the last data point value is greater than 100.

lwidth(str) The line width of the area stroke. The default is lw(0.05).

lcolor(str) The line color of the area stroke. The default is lc(white).

tline Add a timeline which is the running sum of all the layers. Helpful for showing aggregates if cat() is used.

tlwidth(str) The timeline width. The default is tlw(0.3).

tlcolor(str) The timeline color. The default is tlc(black).

tlpattern(str) The timeline pattern. The default is tlp(solid).

labprop Scale the bar labels based on the relative stocks.

labscale(num) Scale factor of labprop. Default value is labscale(0.3333). Values closer to zero result in more exponential scaling, while values closer
to one are almost linear scaling. This is an advanced option so use carefully.

* All other standard twoway options.

Dependencies

The palette package (Jann 2018, 2022) is required for streamplot:

ssc install palettes, replace
ssc install colrspace, replace

Even if you have these installed, it is highly recommended to check for updates: ado update, update

Examples

See GitHub.

Package details

Version : streamplot v1.82
This release : 10 Jun 2024
First release: 06 Aug 2021
Repository : GitHub
Keywords : Stata, graph, stream plot
License : MIT

Author : Asjad Naqvi
E-mail : asjadnaqvi@gmail.com
Twitter : @AsjadNaqvi

Feedback

Please submit bugs, errors, feature requests on GitHub by opening a new issue.

Citation guidelines

Suggested citation guidlines for this package:

Naqvi, A. (2024). Stata package "streamplot" version 1.82. Release date 10 June 2024. https://github.com/asjadnaqvi/stata-streamplot.

@software

References

Jann, B. (2018). Color palettes for Stata graphics. The Stata Journal 18(4): 765-785.

Jann, B. (2022). Color palettes for Stata graphics: An update. University of Bern Social Sciences Working Papers No. 43.

Other visualization packages

arcplot, alluvial, bimap, bumparea, bumpline, circlebar, circlepack, clipgeo, delaunay, joyplot,
marimekko, polarspike, sankey, schemepack, spider, streamplot, sunburst, treecluster, treemap, waffle

or visit GitHub for detailed documentation and examples.