Nodes/ComfyDL/Bar Chart
ComfyUI Node

Bar Chart

Turn a tensor into a bar chart with the numbers written on the bars

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Bar Chart
  • values
  • image
labels
xlabel
ylabel
horizontalfalse
color#4673a6
annotatetrue
figsize_w7.0
figsize_h4.0

CdlBarChart takes a tensor of values and renders them as a bar chart - vertical or horizontal - with the value written on top of each bar by default. It's the node you reach for when you want to see, not just imagine, a distribution: class probabilities from a model head, per-class counts, evaluation scores side by side. Like the rest of ComfyDL's Visualization category, it bakes the chart into a real ComfyUI IMAGE, so it plugs straight into PreviewImage or SaveImage.

How it works

It's matplotlib under the hood - bar for vertical, barh for horizontal. Your values tensor is flattened to a 1-D array of bar heights, and each gets a category label. If you leave labels empty it just numbers them 0, 1, 2, …, which is fine for quick checks and ugly for anything you'd show someone else. annotate (on by default) prints each value on top of its bar, which is a genuinely handy default for evaluation charts.

The styling knobs are what you'd expect: color for the bar face (default is a pleasant muted blue, #4673a6), figsize_w / figsize_h for the figure size, and xlabel / ylabel for the axes. There's also horizontal to flip the whole thing - useful when category names are long and would collide as vertical labels.

Inputs and output

  • values - the cdlTensor of bar heights.
  • labels - comma-separated category names, empty by default.
  • xlabel, ylabel - axis labels.
  • horizontal - boolean, default off.
  • color - hex color string, default #4673a6.
  • annotate - boolean, default on (prints values on bars).
  • figsize_w, figsize_h - figure size, defaults 7×4.

The single output is image, type IMAGE.

Where you'd use it

The README's LeNet example is the template: run a forward pass, take class probabilities, and show them as a bar chart so you can literally see the model's confidence per class. Any time you have a small set of numbers that deserve to be compared visually - validation accuracy across epochs, per-class F1, feature magnitudes - this is the cheapest way to look at them in-graph.

Installing it

It ships with ComfyDL, so one install covers all 106 nodes:

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

Restart ComfyUI, or search "ComfyDL" in ComfyUI Manager. matplotlib is the only new dependency, and it's what every chart node in this pack needs.

Gotchas

  • labels is comma-separated, and mismatches are handled silently: extra labels get truncated to the number of bars. Count them before you paste them in.
  • An empty values tensor renders a "No data" placeholder chart rather than erroring - so a blank chart usually means the upstream tensor is empty.
  • This is a chart-of-what-you-fed-it node; it renders once when the queue item runs, it's not a live plot.
Categoryd2l/Visualization

Inputs (9)

NameTypeDefaultDescription
valuesTENSOR
labelsSTRING
xlabelSTRING
ylabelSTRING
horizontalBOOLEANfalse
colorSTRING#4673a6
annotateBOOLEANtrue
figsize_wFLOAT7.02–20
figsize_hFLOAT4.02–20

Outputs (1)

NameTypeDescription
imageIMAGE