help treeclustertreecluster v1.0 (GitHub)

treecluster

: A Stata package for plotting clustered trees.

The command plots heirarchical data in a tree cluster layout. The last layer determines the placement of higher tier "parent" layers.
The tree layout can be switched between horizontal Cartesian and circular Polar coodinates.

The command is still beta and is subject to change and improvements. Please regularly check the GitHub page for version changes and updates.

Syntax

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) nolabel
xsize(num) ysize(num) aspect(num) ]

treecluster value, by(vars) The command requires a numerical value variable, plotted over a sequence of heirarchical variables defined by by().
The option by() should be specified from higher grouping category to finer categories. If there are imperfect overlaps across by() layers, then lower tier layers
will be split based on higher tier layers. Currently, there is no limit to the number of layers that can be specified. More complex layer combinations will result in longer processing times.

smooth(1-8) The smooth option determines the shape of the line links. A value of 1 is a straight light, while 8 is a stepwise line.
Middle values of 3-5 represent S-shaped logistic curves.

radius(numlist) The gaps on the x-axis or radii can be manually specified here for fine tuning. Note that the number of radii should be exactly equal to the
the number of by() variables. If no option is specified, then the command will automatically use radius increments of 1.

gap(num) The gap option defines the gaps between the layer groups. The number is a percentage of the y-axis length. The default value is gap(2) for 2%.

polar This option converts the graph into a circular polar plot laid out in a circle.

cuts(num) lines are split into equally-spaced intervals based on the highest value. The cuts are used as weights for line widths.
Higher value categories are drawn thicker than lower value categories. The default value is cuts(50).

scalefactor(num) This option can be used to scale the line widths. A lower value implies thinner lines. The default option is scalefac(0.15).

noscale This option simply draws unweighted lines and is definitely much faster than generating scaled connections.

share Show shares (0-100) rather than values in layer labels. Shares add up to 100 for each by() layer.

threshold(value) The cut-off value below which the values are collapsed into one group, and labeled as "Rest of ...". This option is highly useful if
there are a lot of very small barely-discernible categories. Default is thresh(0).

format(str) Format the displayed values. Default for standard values is format(%9.0fc) and for shares it is format(%5.2f).

offset(num) This option is the value by which the x-axis should be extended.
This option is used to accmmodate the labels of the last category. The default value is offset(0.3).

laboffset(num) This option is a the percentage share of the x-axis width of the last category width by which the labels should be extended.
The default value is laboffset(2) for 2%.

lcolor(str) This line colors. The default value is lc(gs13).

labsize(str) This size of the value labels. The default value is labs(1.3).

msymbol(str) The marker symbol. The default value is msym(O) for a circle.

msize(str) The marker size. The default value is msize(1).

mcolor(str) The marker color. The default value is mc(white).

mlcolor(str) The marker outline color. The default value is mc(gs3).

mlwidth(str) The marker outline width.

nolabel Turn off all labels. Mostly to create aesthetically-pleasing minimal layouts.

points(num) Number of points for evaluating the line curves. This option usually does not need to be touched unless a very high resolution image needs to be drawn.
In this case, the number of evaluation points should be increased.
The default value is p(80).

xsize(), ysize(), aspect() These options can be used to finetune graphs. For polar, the options are set equal to 1 each.

title(), subtitle(), note(), name() These are standard twoway graph options.

Dependencies

The palette package (Jann 2018) is required for sunburst:

ssc install palettes, replace
ssc install colrspace, replace

Even if you have these installed, it is highly recommended to update the dependencies:
ado update, update

Examples

See GitHub for examples.

Version history

- 1.0 : First version.

Package details

Version : treecluster v1.0
This release : 30 Dec 2022
First release: 30 Dec 2022
Repository : GitHub
Keywords : Stata, graph, clustered trees
License : MIT

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

Acknowledgements

Feedback

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

References

Other visualization packages

sunburst, sankey, alluvial, circlebar, spider, treemap, circlepack, arcplot,
marimekko, bimap, joyplot, streamplot, delaunay, clipgeo, schemepack