{"id":26334447,"url":"https://github.com/asjadnaqvi/stata-ternary","last_synced_at":"2026-02-13T19:31:45.585Z","repository":{"id":256725020,"uuid":"848791397","full_name":"asjadnaqvi/stata-ternary","owner":"asjadnaqvi","description":"A Stata package for trivariate plots","archived":false,"fork":false,"pushed_at":"2025-05-07T21:10:20.000Z","size":53842,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-01T23:39:20.954Z","etag":null,"topics":["ado","package","stata","ternary","triplot","trivariate"],"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":null,"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}},"created_at":"2024-08-28T12:16:37.000Z","updated_at":"2025-05-07T21:10:23.000Z","dependencies_parsed_at":"2024-09-12T18:54:18.575Z","dependency_job_id":"5a469f99-60cd-4c94-9337-41516f0dc576","html_url":"https://github.com/asjadnaqvi/stata-ternary","commit_stats":null,"previous_names":["asjadnaqvi/stata-ternary"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/asjadnaqvi/stata-ternary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-ternary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-ternary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-ternary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-ternary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asjadnaqvi","download_url":"https://codeload.github.com/asjadnaqvi/stata-ternary/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asjadnaqvi%2Fstata-ternary/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29415563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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","package","stata","ternary","triplot","trivariate"],"created_at":"2025-03-16T00:19:01.245Z","updated_at":"2026-02-13T19:31:45.441Z","avatar_url":"https://github.com/asjadnaqvi.png","language":"Stata","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n![StataMin](https://img.shields.io/badge/stata-2015-blue) ![issues](https://img.shields.io/github/issues/asjadnaqvi/stata-ternary) ![license](https://img.shields.io/github/license/asjadnaqvi/stata-ternary) ![Stars](https://img.shields.io/github/stars/asjadnaqvi/stata-ternary) ![version](https://img.shields.io/github/v/release/asjadnaqvi/stata-ternary) ![release](https://img.shields.io/github/release-date/asjadnaqvi/stata-ternary)\n\n\n[Installation](#Installation) | [Syntax](#Syntax) | [Examples](#Examples) | [Feedback](#Feedback) | [Change log](#Change-log)\n\n---\n\n![ternary_banner](https://github.com/user-attachments/assets/1c0d3590-2469-41b0-88f4-6d8099fb8f75)\n\n\n---\n\n\n# ternary v1.3\n(07 May 2025)\n\nThis package provides the ability to draw tri-variate plots in Stata.\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\nThe SSC version (**v1.2**):\n\n```stata\nssc install ternary, replace\n```\n\nOr it can be installed from GitHub (**v1.3**):\n\n```stata\nnet install ternary, from(\"https://raw.githubusercontent.com/asjadnaqvi/stata-ternary/main/installation/\") replace\n```\n\nThe `palettes` package is required to run this command:\n\n```stata\nssc install palettes, replace\nssc install colrspace, replace\n```\n\nEven if you have the package installed, make sure that it is updated `ado update, update`.\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```stata\nssc install schemepack, replace\nset scheme white_tableau  \n```\n\nYou can also push the scheme directly into the graph using the `scheme(schemename)` option. See the help file for details or the example below.\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\nternary varL varR varB [if] [in], [ by(var) cuts(num) zoom pad(num) normalize(1|100) nofill points lines labels colorL(str) colorR(str)\n\tcolorB(str) lwidth(str) msymbol(str) msize(str) mcolor(str) mlcolor(str) mlwidth(str) labcolor(str) ticksize(str) mlabel(var)\n\tmlabsize(str) mlabcolor(str) mlabposition(str) scale format(fmt) palette(str) legend(options) * ]\n```\n\nSee the help file `help ternary` for details.\n\nThe most basic use is as follows:\n\n```stata\nternary varL varR varB\n```\n\nrepresenting left, right and bottom variables respectively.\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/s459374.html) is recommended. Please note that the GitHub version might be newer than the SSC version.\n\n\n\n## Examples\n\n\nUsers can either copy the files locally \n\n```stata\nforeach x in NUTS2_edu NUTS2_tourstay NUTS3_gva NUTS3_pop {\n\tcopy \"https://github.com/asjadnaqvi/stata-ternary/raw/main/data/`x'.dta\" \"`x'.dta\", replace\n}\n\n```\n\n\nor load them directly from the server:\n\n\n```stata\nuse \"https://github.com/asjadnaqvi/stata-ternary/blob/main/data/NUTS3_pop.dta?raw=true\", clear\n```\n\nTest a basic figure\n\n```stata\nternary y15prop y64prop y99prop\n```\n\n\u003cimg src=\"/figures/ternary1.png\" width=\"100%\"\u003e\n\n\nRearrange the variables and remove the fill\n\n```stata\nternary  y99prop y15prop y64prop, nofill\n```\n\n\u003cimg src=\"/figures/ternary2.png\" width=\"100%\"\u003e\n\n\nTest `ternary` with fractions:\n\n```stata\nternary y99prop y15prop y64prop, norm(1)\n```\n\n\u003cimg src=\"/figures/ternary2_1.png\" width=\"100%\"\u003e\n\n### Colors\n\n\n```stata\nternary  y99prop y15prop y64prop\n```\n\n\u003cimg src=\"/figures/ternary3.png\" width=\"100%\"\u003e\n\n\n```stata\nternary  y99prop y15prop y64prop, lcolor(black)\n```\n\n\u003cimg src=\"/figures/ternary4.png\" width=\"100%\"\u003e\n\n\n### Cuts\n\n```stata\nternary y99prop y15prop y64prop, cuts(3)\n```\n\n\u003cimg src=\"/figures/ternary5.png\" width=\"100%\"\u003e\n\n\n```stata\nternary y99prop y15prop y64prop, cuts(10)\n```\n\n\u003cimg src=\"/figures/ternary6.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, cuts(6)\n```\n\n\u003cimg src=\"/figures/ternary7.png\" width=\"100%\"\u003e\n\n\n### Zoom\n\n```stata\nternary y99prop y15prop y64prop, cuts(6) zoom\n```\n\n\u003cimg src=\"/figures/ternary7_1.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, cuts(6) zoom msize(2.5) mc(black%60) mlc(white)\n```\n\n\u003cimg src=\"/figures/ternary7_2.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, cuts(8) zoom msize(2) mc(black%70)  mlc(white) lw(0.08) labcolor(gs6) \n```\n\n\u003cimg src=\"/figures/ternary7_banner.png\" width=\"100%\"\u003e\n\n\n### labels (v1.1)\n\n```stata\nternary y99prop y15prop y64prop, cuts(8) zoom lw(0.08) labcolor(gs6) mlabel(NUTS_ID)\n```\n\n\u003cimg src=\"/figures/ternary_lab1.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, cuts(8) zoom lw(0.08) labcolor(gs6) ///\n\tmlabel(NUTS_ID)  mlabpos(12)\n```\n\n\u003cimg src=\"/figures/ternary_lab2.png\" width=\"100%\"\u003e\n\n```stata\ngen NUTS_ID2 = NUTS_ID if y99prop \u003e 30\t\n\nternary y99prop y15prop y64prop, cuts(8) zoom lw(0.08) labcolor(gs6) ///\n\tmlabel(NUTS_ID2)  mlabpos(12)\n```\n\n\u003cimg src=\"/figures/ternary_lab3.png\" width=\"100%\"\u003e\n\n\n### Customize colors\n\n```stata\nternary y99prop y15prop y64prop, zoom cuts(6) mcolor(white%60) ///\n\tcolorB(lime) \n```\n\n\u003cimg src=\"/figures/ternary8.png\" width=\"100%\"\u003e\n\n\n```stata\nternary y99prop y15prop y64prop, zoom cuts(6) ///\n\tcolorB(red) colorL(green) colorR(blue)\n```\n\n\u003cimg src=\"/figures/ternary9.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, zoom cuts(4) ///\n\tcolorB(red) colorL(green) colorR(blue) mcolor(white%60) mlc(black) msize(3)\t\n```\n\n\u003cimg src=\"/figures/ternary10.png\" width=\"100%\"\u003e\n\n### other options\n\n```stata\nternary y99prop y15prop y64prop, nofill points zoom cuts(6)\n```\n\n\u003cimg src=\"/figures/ternary11.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, points zoom cuts(6) mlcolor(white)\n```\n\n\u003cimg src=\"/figures/ternary12.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, nofill points zoom cuts(6) lw(0.05) msize(2.5) mlc(white)\n```\n\n\u003cimg src=\"/figures/ternary13.png\" width=\"100%\"\u003e\n\n\n```stata\nternary y99prop y15prop y64prop, nofill lines labels zoom cuts(6) msize(2.5) points malpha(80) mlc(white)\n```\n\n\u003cimg src=\"/figures/ternary14.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, nofill lines labels zoom cuts(6) msize(1.5) \n```\n\n\u003cimg src=\"/figures/ternary15.png\" width=\"100%\"\u003e\n\n\n```stata\nternary y99prop y15prop y64prop, nofill lines labels zoom cuts(6) msize(1.5) mlc(black) mc(white%60)\n```\n\n\u003cimg src=\"/figures/ternary16.png\" width=\"100%\"\u003e\n\n```stata\nternary y99prop y15prop y64prop, nofill lines labels zoom cuts(6) msize(2) mlc(black) mc(white%80) lw(0.3) msym(triangle)\n```\n\n\u003cimg src=\"/figures/ternary17.png\" width=\"100%\"\u003e\n\n\n### v1.2\n\nPlot the raw data and scale the markers to the total population:\n\n```stata\nternary y_Y_GE65 y_Y15_64 y_Y_LT15, zoom lw(0.08) scale  norm(100) mcolor(white%70) msize(0.8)\n```\n\n\u003cimg src=\"/figures/ternary18.png\" width=\"100%\"\u003e\n\n```stata\ngen ctry=substr(NUTS_ID, 1, 2)\n\nternary y_Y_GE65 y_Y15_64 y_Y_LT15 if ctry==\"DE\", zoom lw(0.08) scale  norm(100) mcolor(white%60) msize(0.8) pad(2)\n```\n\n\u003cimg src=\"/figures/ternary19.png\" width=\"100%\"\u003e\n\n\n### v1.3 (by categories)\n\nGenerate a region variable for EU countries:\n\n```stata\n\n*** taken from https://en.wikipedia.org/wiki/EuroVoc\n\ngen region = .\n\nreplace region = 1 if inlist(ctry, \"AT\", \"BE\", \"FR\", \"DE\", \"IE\" , \"LI\", \"LU\", \"MK\")\nreplace region = 1 if inlist(ctry, \"NL\", \"CH\", \"UK\")\n\nreplace region = 2 if inlist(ctry, \"DK\", \"IS\", \"EE\", \"FI\", \"LV\", \"LT\", \"SI\", \"NO\")\n\nreplace region = 3 if inlist(ctry, \"CY\", \"EL\", \"IT\", \"MT\", \"PT\" , \"ES\", \"TR\")\n\nreplace region = 4 if inlist(ctry, \"AL\", \"CZ\", \"HR\", \"HU\", \"PL\", \"RO\", \"RS\")\nreplace region = 4 if inlist(ctry, \"SE\", \"SK\", \"MK\", \"ME\", \"BG\")\n\nlab de region 4 \"Central and Eastern Europe\" 2 \"Northern Europe\" 3 \"Southern Europe\" 1 \"Western Europe\", replace\nlab val region region\n\n```\n\n```stata\nternary y_Y_GE65 y_Y15_64 y_Y_LT15 , by(region) cuts(4)  zoom lw(0.08) norm(100) mcolor(white%70) msize(1.8) pad(2)\n```\n\n\u003cimg src=\"/figures/ternary20_1.png\" width=\"100%\"\u003e\n\n\n```stata\nternary y_Y_GE65 y_Y15_64 y_Y_LT15 , by(region) cuts(4) nofill zoom lw(0.08) norm(100) mcolor(white%70) msize(1.2) pad(2)\n```\n\n\u003cimg src=\"/figures/ternary20_2.png\" width=\"100%\"\u003e\n\n\n```stata\nternary y_Y_GE65 y_Y15_64 y_Y_LT15 , by(region) cuts(2) zoom lw(0.08) norm(100) msymbol(triangle circle square diamond) msize(0.2) pad(2) nofill scale legend(size(2) pos(6) rows(2))\n```\n\n\u003cimg src=\"/figures/ternary20_3.png\" width=\"100%\"\u003e\n\n\n```stata\nternary y_Y_GE65 y_Y15_64 y_Y_LT15, by(region) cuts(2) nofill malpha(100) zoom lw(0.08) norm(100) msymbol(circle) msize(1) pad(2) palette(burd) mlcolor(white) mlwidth(0.06)\n```\n\n\u003cimg src=\"/figures/ternary20_4.png\" width=\"100%\"\u003e\n\n\n\n## Feedback\n\nPlease open an [issue](https://github.com/asjadnaqvi/stata-ternary/issues) to report errors, feature enhancements, and/or other requests. \n\n\n## Change log\n\n**v1.3 (07 May 2025)**\n- Option `by()` added to allow markers to vary by categories.\n- Option `msymbol()` now accepts lists. If there are fewer markers defined than the by categories, then the last marker will be used for the remaining.\n- Option `palette()` added to customize marker colors.\n- Option `legend()` added to control how `by()` legends are drawn.\n- Various bug fixes.\n\n**v1.2 (12 Mar 2025)**\n- Option `fill` is now the default and has been removed. Instead `nofill` has been added to remove the colors. This aligns the package to also how it was intended to be drawn by default.\n- Option `norm(100)` show now work properly.\n- Option `scale` has been added to scale the markers to the total of the raw data. In order to use this correctly, specify the raw data and select `norm(100)` or `norm(1)`.\n- Option `zoom` should now result in tighter bounds.\n- Option `pad()` has been added to extended the zoom bounds. Default is `pad(5)` fof 5%.\n\n**v1.1 (12 Sep 2024)**\n- Added `norm()` option which can be used to normalize the data to 1 (`norm(1)`) or 100 (`norm(100)`).\n- Added marker label options: `mlabel()`, `mlabcolor()`, `mlabposition()`, `mlabsize()`.\n- Better zoom option.\n- Minor code cleanups.\n\n**v1.0 (28 Aug 2024)**\n- First release.\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasjadnaqvi%2Fstata-ternary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasjadnaqvi%2Fstata-ternary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasjadnaqvi%2Fstata-ternary/lists"}