Visualizing Cluster Evolution: Introducing ClustreePlot in CanvasXpress

If you work with clustering — single-cell RNA-seq resolutions, customer segmentation sweeps, or any workflow where you re-run a clustering algorithm at increasing granularity — you've probably asked the same question over and over: how do my clusters at resolution 0.4 relate to the clusters I get at resolution 1.0? Do two coarse clusters split cleanly into finer ones, or do cells get reshuffled across group boundaries as resolution increases?

That question has a well-known visual answer: the clustree diagram — a layered tree where each row is a clustering resolution, each node is a cluster, node size reflects how many observations fall into it, and edges show how observations flow from one resolution's clusters into the next. CanvasXpress now renders this chart natively as a Scatter2D plot type, so you can generate it directly from your data without leaving the library you already use for the rest of your analysis.

How it works

A clustree plot is really a Scatter2D chart wearing a very specific layout. Instead of plotting raw (x, y) measurements, CanvasXpress computes node coordinates for you: the vertical axis (or horizontal, if you flip orientation) represents clustering resolution level, and within each level, nodes are ordered to minimize crossing edges between levels — the same kind of layered, barycenter-based ordering used in classic hierarchical/layered graph layouts.

Because it's built on Scatter2D, the chart gets to reuse machinery you already know:

Getting data in

You can feed a clustree chart in the most natural shape for clustering output: a dataset with one column per resolution (e.g., res_0.1, res_0.5, res_1.0), each holding the cluster label assigned to every observation at that resolution. CanvasXpress reshapes that matrix internally into the nodes and transition edges needed to draw the tree. If you already have a precomputed node/edge structure, you can supply it directly instead.

Configuring the chart

Turning any Scatter2D chart into a clustree plot is a matter of setting scatterType to "clustree" and adjusting a handful of dedicated options — orientation, palettes, edge styling, labels, and axis display are all exposed as ordinary configuration properties:

var cx = new CanvasXpress("chartContainer", data, {
  graphType: "Scatter2D",
  scatterType: "clustree",
  clustreePrefix: "p",
  clustreeFlip: false,
  clustreeSweeps: 4,
  clustreeNodePalette: "Paired",
  clustreeEdgePalette: "Spectral",
  clustreeEdgeArrows: true,
  clustreeNodeLabels: true,
  clustreeShowEdgeLegend: true
});

A few options worth knowing:

Because the chart is still a standard CanvasXpress object under the hood, everything you already rely on works the same way. You can update the underlying data with cx.updateData(...) as new resolutions come in, adjust any clustree option with cx.updateConfig(...) and redraw immediately, or resize the chart with cx.setDimensions(...). Calling cx.getConfig() returns the fully resolved configuration, including every clustree-specific setting, which is useful if you're building a UI that lets users toggle orientation or palettes interactively.

Exploring and sharing

Right-clicking a clustree chart surfaces a dedicated context-menu section for flipping orientation, toggling axis display, and removing the clustree layer — no need to dig through a general settings panel. The same options are also available through CanvasXpress's visual Customizer panel, under its own Clustree tool group, for users who prefer a guided interface over editing configuration directly.

And because every CanvasXpress chart is self-describing, you get the same save/share workflow as any other plot: use Save as JSON from the chart's File menu to capture the exact chart state, drag that saved file back onto a chart container to reload it instantly, or use the Reproduce toolbar action to replay the chart's construction step by step — useful for documenting how a particular clustree layout was built, or for sharing a reproducible figure with collaborators.

Clustree plots join CanvasXpress's growing set of specialized chart types built on a shared, battle-tested rendering core — so the plot you use to explore clustering resolutions looks and behaves consistently with everything else in your dashboard.