{"id":26334441,"url":"https://github.com/asjadnaqvi/stata-streamplot","last_synced_at":"2026-02-16T21:33:28.995Z","repository":{"id":40991898,"uuid":"480320966","full_name":"asjadnaqvi/stata-streamplot","owner":"asjadnaqvi","description":"A Stata package for stream plots","archived":false,"fork":false,"pushed_at":"2025-03-24T19:26:12.000Z","size":19842,"stargazers_count":15,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-26T13:07:30.150Z","etag":null,"topics":["ado","graph","stata","streamplot"],"latest_commit_sha":null,"homepage":"","language":"Stata","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asjadnaqvi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"asjadnaqvi"}},"created_at":"2022-04-11T09:55:22.000Z","updated_at":"2025-06-28T19:17:11.000Z","dependencies_parsed_at":"2024-04-30T14:08:17.470Z","dependency_job_id":"f43da8a9-937c-4de1-ae2e-53a73ede6f9b","html_url":"https://github.com/asjadnaqvi/stata-streamplot","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/asjadnaqvi/stata-streamplot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-streamplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-streamplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-streamplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-streamplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asjadnaqvi","download_url":"https://codeload.github.com/asjadnaqvi/stata-streamplot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-streamplot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29519413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T18:37:19.720Z","status":"ssl_error","status_checked_at":"2026-02-16T18:36:46.920Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ado","graph","stata","streamplot"],"created_at":"2025-03-16T00:18:59.676Z","updated_at":"2026-02-16T21:33:28.968Z","avatar_url":"https://github.com/asjadnaqvi.png","language":"Stata","funding_links":["https://github.com/sponsors/asjadnaqvi"],"categories":[],"sub_categories":[],"readme":"\n\n![StataMin](https://img.shields.io/badge/stata-2015-blue) ![issues](https://img.shields.io/github/issues/asjadnaqvi/stata-streamplot) ![license](https://img.shields.io/github/license/asjadnaqvi/stata-streamplot) ![Stars](https://img.shields.io/github/stars/asjadnaqvi/stata-streamplot) ![version](https://img.shields.io/github/v/release/asjadnaqvi/stata-streamplot) ![release](https://img.shields.io/github/release-date/asjadnaqvi/stata-streamplot)\n\n\n[Installation](#Installation) | [Syntax](#Syntax) | [Citation guidelines](#Citation-guidelines) |  [Examples](#Examples) | [Feedback](#Feedback) | [Change log](#Change-log)\n\n---\n\n\n![streamplot](https://github.com/asjadnaqvi/stata-streamplot/assets/38498046/4b7bbaab-8667-4f47-a119-ec93dcd607a3)\n\n\n# streamplot v1.9\n(08 Feb 2024)\n\nThis package provides the ability to generate stream plots in Stata. It is based on the [Streamplot Guide](https://medium.com/the-stata-guide/covid-19-visualizations-with-stata-part-10-stream-graphs-9d55db12318a) (December 2020).\n\n\n## Installation\n\nThe package can be installed via SSC or GitHub. The GitHub version, *might* be more recent due to bug fixes, feature updates etc, and *may* contain syntax improvements and changes in *default* values. See version numbers below. Eventually the GitHub version is published on SSC.\n\nSSC (**v1.9**):\n```\nssc install streamplot, replace\n```\n\nGitHub (**v1.9**):\n\n```\nnet install streamplot, from(\"https://raw.githubusercontent.com/asjadnaqvi/stata-streamplot/main/installation/\") replace\n```\n\n\nThe following dependencies are required:\n\n```stata\nssc install palettes, replace\nssc install colrspace, replace\nssc install graphfunctions, replace\n```\n\nIf you want to make a clean figure, then it is advisable to load a clean scheme. These are several available and I personally use the following:\n\n```\nssc install schemepack, replace\nset scheme white_tableau  \n```\n\nI also prefer narrow fonts in figures with long labels. You can change this as follows:\n\n```stata\ngraph set window fontface \"Arial Narrow\"\n```\n\n\n## Syntax\n\nThe syntax for the latest version is as follows:\n\n```stata\nstreamplot y x [if] [in], by(varname) \n            [ palette(str) smooth(num) labcond(str) offset(num) alpha(num) yreverse cat(varname) \n               recenter(top|mid|bot) lcolor(str) lwidth(str) labsize(num) labcolor(color|palette)\n               percent format(str) area nolabel wrap(num) tline tlcolor(str) tlwidth(str) \n               tlpattern(str) yline(str) labprop labscale(num) wrap(num) *\n            ]\n```\n\nSee the help file `help streamplot` for details.\n\nThe most basic use is as follows:\n\n```stata\nstreamplot y x, by(varname)\n```\n\nwhere `y` is the variable we want to plot, and `x` is usually the time dimension. The `by` variable splits the data into different groupings that also determines the colors. The color schemes can be modified using the `palettes(name)` option. Here any scheme from the `colorpalettes` package can be used.\n\n\n## Citation guidelines\nSoftware packages take countless hours of programming, testing, and bug fixing. If you use this package, then a citation would be highly appreciated. \n\nThe [SSC citation](https://ideas.repec.org/c/boc/bocode/s459060.html) is recommended. Please note that the GitHub version might be newer than the SSC version.\n\n\n\n## Examples\n\nSet up the data:\n\n```stata\nclear\nset scheme white_tableau\ngraph set window fontface \"Arial Narrow\"\n\nuse \"https://github.com/asjadnaqvi/stata-streamplot/blob/main/data/streamdata.dta?raw=true\", clear\n\n```\n\nWe can generate basic graphs as follows:\n\n```stata\nstreamplot new_cases date, by(region) \n```\n\n\u003cimg src=\"/figures/streamplot1.png\" width=\"100%\"\u003e\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6)\n```\n\n\u003cimg src=\"/figures/streamplot2.png\" width=\"100%\"\u003e\n\nRecenter the graphs to top or bottom:\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) recenter(bot)\n```\n\n\u003cimg src=\"/figures/streamplot2_1.png\" width=\"100%\"\u003e\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) recenter(top)\n```\n\n\u003cimg src=\"/figures/streamplot2_2.png\" width=\"100%\"\u003e\n\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) ///\n\tlabcond(20000) ylabsize(1.8) lc(black) lw(0.04)\n```\n\n\u003cimg src=\"/figures/streamplot3.png\" width=\"100%\"\u003e\n\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) ///\n\tlabcond(20000) ylabsize(1.8) lc(black) lw(0.04) format(%12.0fc) offset(20)\n```\n\n\u003cimg src=\"/figures/streamplot3_1.png\" width=\"100%\"\u003e\n\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) palette(CET D11) ///\n\tlabcond(2) ylabsize(1.8) lc(black) lw(0.04)  percent format(%3.2f) offset(20) ylabc(red)\n```\n\n\u003cimg src=\"/figures/streamplot3_2.png\" width=\"100%\"\u003e\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) palette(CET C6, reverse) ///\n\tlabcond(1) ylabsize(1.8) lc(black) lw(0.04)  percent format(%3.2f) offset(20) ylabc(palette)\n```\n\n\u003cimg src=\"/figures/streamplot3_3.png\" width=\"100%\"\u003e\n\n\nTest label wrapping and condition the labels:\n\n```stata\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) palette(CET C6, reverse) wrap(25) labprop ///\n\tlabcond(4e4) labsize(1.8) lc(black) lw(0.04)  offset(20) labc(palette)\n```\n\n\u003cimg src=\"/figures/streamplot3_4.png\" width=\"100%\"\u003e\n\n```stata\nqui summ date if date \u003e 22400\n\nlocal xmin = `r(min)'\nlocal xmax = `r(max)'\n\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) palette(CET D02)  ///\n\ttitle(\"My Stata stream plot\") /// \n\tsubtitle(\"Subtitle here\") note(\"Note here\") ///\n\tlabcond(20000) ylabsize(1.5) lc(white) lw(0.08) ///\n\txlabel(`xmin'(20)`xmax', angle(90)) xtitle(\"\")\n```\n\n\u003cimg src=\"/figures/streamplot4.png\" width=\"100%\"\u003e\n\n\n\n\nor a custom graph scheme:\n\n```stata\nstreamplot new_cases date if date \u003e 22600, by(region) smooth(6)  palette(CET CBD1)  ///\n\ttitle(\"My Stata stream plot\", size(6)) subtitle(\"with colorblind-friendly colors\", size(4))  ///\n\tlabcond(20000) ylabs(2) lc(black) lw(0.03) offset(25) xtitle(\"\") ///\n\tscheme(neon) \n```\n\nwhere the dark background `neon` scheme is loaded from the [schemepack](https://github.com/asjadnaqvi/stata-schemepack) suite.\n\n\n\u003cimg src=\"/figures/streamplot5.png\" width=\"100%\"\u003e\n\n\n## v1.6 updates\n\nTest the `yreverse` option:\n\n```\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) ///\n\tlabcond(20000) ylabsize(1.8) lc(black) lw(0.04) format(%12.0fc) offset(20) yrev\n```\n\n\u003cimg src=\"/figures/streamplot6.png\" width=\"100%\"\u003e\n\n\nTest the region split option. First let's define a variable:\n\n```\ngen ns = .\nreplace ns = 2 if inlist(region, 1, 2, 5, 6, 7, 8)\nreplace ns = 1 if inlist(region, 3, 4, 9, 10, 11, 12, 13)\n\nlab de ns 2 \"North\" 1 \"South\"\nlab val ns ns\n\ntab region ns\n```\n\nAnd plot it:\n\n```\nstreamplot new_cases date if date \u003e 22400, by(region) smooth(6) cat(ns) palette(CET D02) labcond(20000)\n```\n\n\u003cimg src=\"/figures/streamplot7.png\" width=\"100%\"\u003e\n\n\nWe can use the new variable itself in the `by()` option:\n\n\n```\nstreamplot new_cases date if date \u003e 22400, cat(ns) by(ns) smooth(6) \n```\n\n\u003cimg src=\"/figures/streamplot8.png\" width=\"100%\"\u003e\n\n## v1.7 updates\n\nGet the data:\n\n```\nuse \"https://github.com/asjadnaqvi/stata-streamplot/blob/main/data/wbgdpdata.dta?raw=true\", clear\n\ndrop if year \u003c 1990\ngen splitvar = category!=\"M\"\n```\n\n\n```\nstreamplot value_real year if countrycode==\"TSA\", by(category) smooth(2) xsize(2) ysize(1)\n```\n\n\u003cimg src=\"/figures/streamplot_tline1.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year if countrycode==\"TSA\", by(category) cat(splitvar) smooth(2)  xsize(2) ysize(1) \n```\n\n\u003cimg src=\"/figures/streamplot_tline2.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year if countrycode==\"TSA\", by(category) cat(splitvar) smooth(2) palette(tab Green-Orange-Teal) ///\n\tyline(0) xsize(2) ysize(1) \n```\n\n\u003cimg src=\"/figures/streamplot_tline3.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year if countrycode==\"TSA\", by(category) cat(splitvar) smooth(2) palette(tab Green-Orange-Teal) ///\n\tyline(0) xsize(2) ysize(1) tline \n```\n\n\u003cimg src=\"/figures/streamplot_tline4.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year if countrycode==\"TSA\", by(category) cat(splitvar) smooth(2) palette(tab Nuriel Stone) ///\n\tyline(0) xsize(2) ysize(1) tline tlc(white) tlw(0.8) tlp(dash)\t\n```\n\n\u003cimg src=\"/figures/streamplot_tline5.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year if countrycode==\"TSA\", by(category) cat(splitvar) smooth(2) palette(tab Green-Orange-Teal) ///\n\tyline(0) xsize(2) ysize(1) tline tlc(black) tlw(0.5) tlp(dash)\t\n```\n\n\u003cimg src=\"/figures/streamplot_tline6.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year if countrycode==\"TSA\", by(category) cat(splitvar) smooth(2) palette(tab Green-Orange-Teal) ///\n\tyline(0) xsize(2) ysize(1) tline tlc(black) tlw(0.5) tlp(dash) xtitle(\"\") ///\n\txlabel(1990(2)2022, angle(90)) labsize(2.2) offset(8) \t///\n\ttitle(\"{fontface Arial Bold:GDP Expenditures in South Asia (Constant 2015 USD billions)}\")\t///\n\tnote(\"World Bank Open Data.\", size(2))\n```\n\n\u003cimg src=\"/figures/streamplot_tline7.png\" width=\"100%\"\u003e\n\n\n## v1.8 updates\n\n```stata\nstreamplot value_real year if countrycode==\"TSA\", by(category) cat(splitvar) smooth(2) palette(tab Green-Orange-Teal) ///\n\tyline(0) xsize(2) ysize(1) tline tlc(black) tlw(0.5) tlp(dash) xtitle(\"\") xline(2020) ///\n\txlabel(1990(2)2022, angle(90)) labsize(2.2) offset(8) labprop \t///\n\ttitle(\"{fontface Arial Bold:GDP Expenditures in South Asia (Constant 2015 USD billions)}\")\t///\n\tnote(\"World Bank Open Data.\", size(2))\n```\n\n\u003cimg src=\"/figures/streamplot_labprop1.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year  if countrycode==\"TSA\", by(category) smooth(2) palette(tab Green-Orange-Teal) ///\n\txsize(2) ysize(1) xtitle(\"\") ///\n\txlabel(, angle(90)) labsize(2.2) offset(8) recenter(bottom)  labprop  \t///\n\ttitle(\"{fontface Arial Bold:GDP Expenditures in South Asia (Constant 2015 USD billions)}\")\t///\n\tnote(\"World Bank Open Data.\", size(2)) \n```\n\n\u003cimg src=\"/figures/streamplot_labprop2.png\" width=\"100%\"\u003e\n\n```\nstreamplot value_real year  if countrycode==\"TSA\", by(category) smooth(2) palette(tab Green-Orange-Teal) ///\n\txsize(2) ysize(1) xtitle(\"\")  ///\n\txlabel(, angle(90)) labsize(2.2) offset(8) recenter(bottom) labprop labcolor(palette)  \t///\n\ttitle(\"{fontface Arial Bold:GDP Expenditures in South Asia (Constant 2015 USD billions)}\")\t///\n\tnote(\"World Bank Open Data.\", size(2)) \n```\n\n\u003cimg src=\"/figures/streamplot_labprop3.png\" width=\"100%\"\u003e\n\n\n## v1.81 stacked area graph\n\n```\nstreamplot value_real year  if countrycode==\"TSA\", by(category) smooth(0) area recenter(bottom)  ///\n\txsize(2) ysize(1) xtitle(\"\") palette(tab Green-Orange-Teal)  ///\n\txlabel(, angle(90)) labsize(2.2) offset(8)   \t///\n\ttitle(\"{fontface Arial Bold:GDP Expenditures in South Asia (Constant 2015 USD billions)}\")\t///\n\tnote(\"World Bank Open Data.\", size(2))  \n```\n\n\u003cimg src=\"/figures/streamplot_labprop4.png\" width=\"100%\"\u003e\n\n\n## Feedback\n\nPlease open an [issue](https://github.com/asjadnaqvi/stata-streamplot/issues) to report errors, feature enhancements, and/or other requests.\n\n\n## Change log\n\n**v1.9 (08 Feb 2025)**\n- `droplow` has been taken out. All categories are now plotted even if they have one observation. If categories end in the middle, they are not labeled.\n- The option `wrap` now requires the [graphfunctions](https://github.com/asjadnaqvi/stata-graphfunctions) package. Word boundaries are now respected.\n- `laboffset()` added to displace labels. Negative values would make the labels closer to the stream.\n- Fixed several bugs.\n\n**v1.82 (10 Jun 2024)**\n- Added `wrap()` option for label wrapping.\n- Minor code fixes.\n\n**v1.81 (30 Apr 2024)**\n- Added `area` option to allow stacked area graphs.\n\n**v1.8 (25 Apr 2024)**\n- Added `labprop` and `labscale()` options to allow easy label scaling.\n- Added `share` and `percent` as substitutes.\n- Major code rework to optimize the speed of the graph generation.\n- Generic twoway options added.\n- \n\n**v1.7 (01 Apr 2024)**\n- Added trendline options: `tline`, `tlcolor()`, `tlpattern()`, `tlwidth()`.\n- Added additional checks for plotting data.\n- Better handling of missing values and categories.\n\n**v1.61 (15 Jan 2024)**\n- Fixed issues with locals.\n- Change `ylabcolor()` and `ylabsize()` to `labcolor()` and `labsize()` respectively.\n\n**v1.6 (15 Oct 2023)**\n- Major update with the `cat()` option added to compare top versus bottom streams.\n- Option `yreverse` fixed.\n- Option `nolab` fixed.\n- Several internal routines rewritten and cleaned up.\n- The option `percent()` is now defined in the 0-100 (or higher range). Changed from the 0-1 range.\n\n**v1.52 (25 Aug 2023)**\n- Support for `aspect()`, `saving()`, `xscale()`, and `graphregion()` added.\n\n**v1.51 (28 May 2023)**\n- Cleaned up `labcond()` to align it with other packages.\n- `offset()` changed to percentages to align it with other packages.\n- Minor code cleanups, updates to defaults, and help file.\n\n**v1.5 (20 Nov 2022)**\n- Option to recenter the graphs added. \n- Improve the precision of the calculations.\n\n**v1.4 (08 Nov 2022)**\n- Major code cleanup.\n- The command now does error checks on the number of observations.\n- The command now correct deals with sequence of variables.\n- Additional `colorpalette` options added. \n- Several fixes to the help file.\n\n**v1.3 (20 Jun 2022)**\n- ado distribution date added.\n- ylabel color, format, and percentages added (Thanks to Marc Kaulisch who suggested and contributed to these options).\n- Fixes to variables precisions.\n- y-label color fixed. Labels can either take on a named color, or they can be assigned the same colors as the color palette.\n\n**v1.2 (06 Jun 2022)**\n- Fixes to value labels no passing through to graphs (Thanks to Marc Kaulisch).\n- Several graph options modified to passthru for better integration with twoway options.\n- Smoothing parameter adjusted\n- Error checks added. If there are too few observations per group, the command will abort.\n\n**v1.1 (08 Apr 2022)**\n- Public release. Several options and features added.\n\n**v1.0 (06 Aug 2021)**\n- Beta version\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasjadnaqvi%2Fstata-streamplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasjadnaqvi%2Fstata-streamplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasjadnaqvi%2Fstata-streamplot/lists"}