Nodes/ComfyDL/Pie Chart
ComfyUI Node

Pie Chart

When you need to actually see your label distribution

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Pie Chart
  • values
  • image
labels
donutfalse
explode
pctdistance0.60
shadowfalse
figsize_w6.0
figsize_h6.0

Before you train anything, you should know your data. Is your class distribution balanced or is 90% of your dataset one class? CdlPieChart gives you that answer as a matplotlib pie - or donut - rendered into a ComfyUI IMAGE you can preview, save, or pipe into anything downstream. It's ComfyDL's answer to "I have a counts tensor and I want to see it."

The whole ComfyDL pack is a port of the Dive into Deep Learning textbook, and this is one of its visualization utilities. It's not going to win awards for chart sophistication - it's a plain matplotlib.pyplot.pie wrapper - but for a quick distribution check inside a node graph, that's exactly the right tool.

The inputs

  • values - a 1-D cdlTensor of slice values. The only required tensor.
  • labels - comma-separated category names. Leave empty and you get the default auto labels.
  • donut - hollow it out into a donut chart. Mostly cosmetic, but donuts read better when you have many small slices.
  • explode - comma-separated 0/1 per slice; a 1 pulls that slice out from the center. Handy for highlighting the minority class.
  • pctdistance - how far the percentage labels sit from the center (default 0.6).
  • shadow, figsize_w, figsize_h - the usual suspects.

The output is a single image tensor ([1, H, W, C]), rendered through matplotlib's Agg backend and converted to a standard ComfyUI IMAGE. That's the nice part about the visualization nodes in this pack: unlike the cdlTensor/cdlModel plumbing that only talks to itself, these emit plain IMAGE, so you can feed the chart into a Preview node, Save Image, or any stock image node.

Installing ComfyDL

Light install, as with the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
cd ComfyDL && pip install -r requirements.txt

Restart ComfyUI; it's under ComfyDL → Visualization. Or search "ComfyDL" in ComfyUI Manager. matplotlib is the only extra dependency, and no model files are involved.

Gotchas and honest advice

Pie charts are a controversial data-viz choice for good reasons - humans are bad at comparing angles. For more than ~6 categories, a bar chart (ComfyDL has Bar Chart too) will almost always serve you better. But for a quick "is this split 50/50 or 90/10" gut check, a pie is fine, and the explode toggle makes the odd category obvious at a glance.

Shape-wise, values must be 1-D and labels count must match the number of slices - mismatches throw matplotlib errors. And explode expects exactly one 0/1 per slice; if you leave it empty (the default) you get no explosion at all. Minor, but the error messages are the "unhelpful matplotlib traceback" variety, so it's worth pre-checking.

Where this node genuinely shines in the ComfyDL world: after a training run, tally predicted class counts into a tensor, feed it here, and you've got an instant visual on whether your model is collapsing into one class. That's a real debugging signal, and it's one wire away.

Categoryd2l/Visualization

Inputs (8)

NameTypeDefaultDescription
valuesTENSOR
labelsSTRING
donutBOOLEANfalse
explodeSTRING
pctdistanceFLOAT0.600.1–1.5
shadowBOOLEANfalse
figsize_wFLOAT6.03–20
figsize_hFLOAT6.03–20

Outputs (1)

NameTypeDescription
imageIMAGE