The 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.
SSC (v1.0):
ssc install treecluster, replace
GitHub (v1.0):
net install treecluster, from("https://raw.githubusercontent.com/asjadnaqvi/stata-treecluster/main/installation/") replace
If 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:
ssc install schemepack, replace
set scheme white_tableau
I also prefer narrow fonts in figures with long labels. You can change this as follows:
graph set window fontface "Arial Narrow"
The syntax for v1.0 is as follows:
treecluster value [if] [in], by(variables)
[ smooth(num) radius(num) gap(num) polar cuts(num) scalefactor(num)
noscale share offset(num) laboffset(num) lcolor(str) lwidth(str)
title(str) subtitle(str) note(str) scheme(str) name(str)
xsize(num) ysize(num) aspect(num) ]
See the help file help treecluster
for details.
The most basic use is as follows:
treecluster value, by(variables)
Load the Stata dataset
use "https://github.com/asjadnaqvi/stata-treecluster/blob/main/data/sunburst.dta?raw=true", clear
gen world = "World"
Let's test the treecluster
command:
treecluster value, by(continent region country)
treecluster value, by(continent region country) threshold(2000)
treecluster value, by(world continent region country) threshold(2000)
treecluster value, by(world continent region country) threshold(2000) noscale
treecluster value, by(world continent region country) threshold(2000) scalefac(0.1)
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1)
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1) smooth(8)
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1) smooth(8) offset(0.7)
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1) smooth(8) radius(1 2 4 8) lc(eltblue) offset(0.7)
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1) smooth(8) radius(1 2 4 8) lc(eltblue) offset(1) xsize(4) ysize(5)
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1) smooth(8) radius(1 2 4 8) lc(eltblue) offset(1) share xsize(4) ysize(5)
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1) smooth(8) radius(1 2 4 8) lc(eltblue) offset(0.7) share
treecluster value, by(world continent region country) threshold(2000) gap(2) scalefac(0.1) radius(1 2 4 6) lc(blue)share polar
treecluster value, by(world continent region country) threshold(2000) gap(5) scalefac(0.1) radius(1 2 4 8) lc(blue%70) offset(0.3) laboffset(1.8) polar
Image for the banner
treecluster value, by(world continent region country) thresh(100) gap(2) scalefac(0.08) lc(maroon%90) offset(0) laboff(0) polar nolab mlcolor(maroon)
Please open an issue to report errors, feature enhancements, and/or other requests.
v1.0 (30 Dec 2022)
- Public release.