SNS Histogram Pt
Histogram a tensor directly — no DataFrame detour
- tens
- IMAGE
SNS Histogram Pt is the "skip the pandas step" variant of the histogram. Instead of a DATAFRAME, it takes a raw PyTorch tensor and bins one of its columns into a Seaborn histogram, straight to an image. The classic use is inspecting data that never was a DataFrame - like plotting the red-channel pixel distribution of an image tensor, which is exactly the demo in the pack's README. You generate, you look at the histogram, you decide whether that channel is blown out.
The inputs
- tens - the
TENSORinput. Rank 1 or 2 works; anything rank 3 and up throwsOnly rank 1 or 2 tensors are supported.A rank-1 tensor (a single series of values) is treated as one column. - y_axis_dims - which column(s) of the tensor to histogram, as a string like
0or1,2. - bins - 2 to 200, default 10. This is the knob you'll actually touch; bump it when 10 buckets smears your data into a plateau.
- title, y_axis_label, style, palette - labels and the usual Seaborn theming.
Output is an IMAGE - the rendered histogram, normalized to a float tensor you can save or preview like any generated image.
How it works
It parses y_axis_dims with ast.literal_eval, so a bare 1 or a list-ish string both work, then calls sns.histplot on the selected column (moved to CPU via .detach().cpu().numpy()), renders the figure to a PNG, and converts it. One honest gotcha from the source: the loop that iterates your listed dims currently breaks after the first one, with a TODO comment in the code. So today, list 0,1,2 and you'll get one histogram, not three. It's not you - the multi-series behavior just isn't built yet. Plot one column at a time.
Where the tensor comes from
This is the subtle part. The SNS * Pt plotting nodes still ship in this pack, but the author's March 2025 update moved the PyTorch wrapper nodes (the ones that produce TENSOR data) into a separate companion extension, ComfyUI-Pt-Wrapper. To actually feed this node - say, to histogram image pixels - you'll usually want that extension installed too. Grab both.
Installing it
The pack install is the standard one: ComfyUI Manager → search "Data analysis" → ComfyUI-Data-Analysis → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
Rename the folder to data-analysis or the example workflows break. No GPU needed; the pack pulls pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl and lxml as pip deps that stock ComfyUI lacks - Manager installs them, or pip install -r requirements.txt by hand.
Troubleshooting
Rank errors mean your tensor is too deep - squeeze it first, or feed a single series. If the histogram comes out empty or the plot looks like a comb, your bins are too high for the data range, not a sign of a broken node. And if you're missing the node entirely, the almost-certain cause is that seaborn (or a sibling dep) never got installed.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| tens | TENSOR | — | |
| y_axis_dims | STRING | — | |
| title | STRING | — | |
| y_axis_label | STRING | — | |
| bins | INT | 102–200 | — |
| style | STRING | — | |
| palette | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |