ComfyUI Node

Plot

The MATLAB-style line plot hiding inside ComfyUI

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Plot
  • X
  • Y
  • image
xlabelx
ylabely
xscalelinear
yscalelinear
figsize_w6.0
figsize_h4.0
legend
xlim_min-1.0
xlim_max-1.0
ylim_min-1.0
ylim_max-1.0

Training a model is watching numbers change and asking "is that good or bad?" CdlPlot turns the numbers into a line. It's a faithful port of d2l's plot - the MATLAB-style plotting utility that appears on nearly every page of the Dive into Deep Learning book - and in ComfyDL it's how you visualize loss curves, learning-rate schedules, or any 1-D series that flows through your graph.

This is the single most useful visualization node in the pack, honestly. The whole point of ComfyDL is doing real deep learning in a node graph, and the one thing every training run produces is a monotonically (hopefully) decreasing loss curve. CdlPlot is how you see it.

How it works

You hand it X and Y tensors plus a pile of matplotlib kwargs, and it renders a line plot through matplotlib's Agg backend, converts the figure to a standard ComfyUI IMAGE tensor ([1, H, W, C]), and hands it back. Because the output is plain IMAGE - not the pack's private cdlTensor type - you can plug it straight into a Preview node, Save Image, or any stock ComfyUI image node.

Inputs that matter

  • X, Y - the data. Both optional cdlTensors: X can be 1-D or 2-D (multiple series as rows), Y likewise. Feed Y alone for an implicit index plot. For a classic training curve: X = step numbers, Y = loss tensor from your loss node.
  • xlabel, ylabel - default to "x"/"y"; set them to something meaningful, it's a chart after all.
  • xscale, yscale - linear or log. Log-scale is the one you'll actually use - loss curves and learning rates both look far better on log axes.
  • legend - comma-separated legend labels, one per series.
  • xlim_min/xlim_max, ylim_min/ylim_max - only take effect when min < max (the -1 defaults are "unset"). Handy for zooming into the interesting part of a long run.
  • figsize_w/figsize_h - figure size in inches, default 6×4.

Installing ComfyDL

As with every node in this pack, install once, use everywhere:

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. ComfyUI Manager: search "ComfyDL". Dependency footprint is matplotlib and nothing else - no model downloads.

Where people get stuck

The multi-series shapes are the usual trap. If you want three curves, Y should be [3, T] (three rows of T points) and X either a single [T] shared axis or its own [3, T]. Feed a [T, 3] and the node reads it as three series of length 3 - nonsense but plotted happily. When your chart comes out looking like a knot, transpose your tensor first.

Also: if X is left unconnected, you get an implicit integer index, which is fine for loss-vs-step plots. But wire the real step numbers in if you're comparing two runs with different lengths - an implicit index will happily overlay misaligned curves and make you think the training is converging when it isn't.

For one-off checks this is the node to reach for. If you want the plot embedded in the graph as a live display, note this pack ships an output-node variant of its heatmap visualizer but CdlPlot itself returns an IMAGE - so just terminate it with a Preview node and you're done.

Categoryd2l/Visualization

Inputs (13)

NameTypeDefaultDescription
xlabelSTRINGx
ylabelSTRINGy
xscaleCOMBOlinear2 options: linear, log
yscaleCOMBOlinear2 options: linear, log
figsize_wFLOAT6.01–30
figsize_hFLOAT4.01–30
XoptTENSOR
YoptTENSOR
legendoptSTRING
xlim_minoptFLOAT-1.0-1000000000–1000000000
xlim_maxoptFLOAT-1.0-1000000000–1000000000
ylim_minoptFLOAT-1.0-1000000000–1000000000
ylim_maxoptFLOAT-1.0-1000000000–1000000000

Outputs (1)

NameTypeDescription
imageIMAGE