Histogram
See the distribution inside a tensor in one glance
- tensor
- image
CdlHistogram flattens a tensor and draws a histogram of its values - the fastest way to answer "what do these numbers actually look like?" A mean and a standard deviation can hide a lot; a histogram shows you the whole shape: whether a loss curve's values cluster near zero or spread into a long tail, whether your gradient magnitudes are healthy or exploding, whether your "clean" feature tensor is secretly full of dead zeros. This node is the ComfyDL Visualization-category workhorse for exactly that, and like its siblings it returns a real ComfyUI IMAGE.
How it works
The tensor goes to numpy and gets flattened to 1-D, then it's fed to matplotlib.pyplot.hist. You control the resolution with bins (default 30, up to 200), the look with color and alpha, and the labels with title, xlabel, ylabel. The density toggle normalizes the histogram so the bars sum to 1 as a probability density - the shape stays the same but the y-axis becomes "share of values per unit," which is what you want when comparing distributions of different sizes.
One thoughtful detail: an empty tensor renders a polite "No data" placeholder chart instead of crashing, which makes silent upstream failures visible as a blank chart rather than a red error.
Inputs and output
tensor- thecdlTensorto histogram (any shape; it's flattened).bins- 5–200, default 30.density- boolean, default off.color- bar color string, default#4673a6.alpha- transparency 0.1–1.0, default 0.7.title,xlabel,ylabel- text, empty by default.
The output is image, type IMAGE - straight into PreviewImage or SaveImage.
Where you'd use it
The README's linear-regression example is the canonical use: it histograms the residuals to show that your fitted model's errors are (hopefully) roughly normal around zero. Beyond that: gradient norms before and after clipping, per-channel image values, activation distributions, random-tensor sanity checks. If you're debugging why training isn't converging, a histogram of the gradients usually tells you more than staring at the loss number.
Installing it
It ships with ComfyDL, one install for 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 dependency this pack adds, and it's the one to check if chart nodes fail.
Gotchas
- With
densityoff (the default), the y-axis is raw counts, which depend on how many elements the tensor has. Turn it on when comparing tensors of different sizes. - A "No data" chart means the input tensor was empty - chase that upstream, it's a clue, not a feature.
- Histograms of tensors with extreme outliers (say, one value at 1e6 among thousands near 1) will be almost unreadable - the whole bar range compresses. That's your data telling you something, though.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| tensor | TENSOR | — | |
| bins | INT | 305–200 | — |
| density | BOOLEAN | false | — |
| color | STRING | #4673a6 | — |
| alpha | FLOAT | 0.700.1–1 | — |
| title | STRING | — | |
| xlabel | STRING | — | |
| ylabel | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |