Nodes/ComfyUI-Data-Analysis/SNS Scatter Plot Pt
ComfyUI Node

SNS Scatter Plot Pt

Scatter a tensor, skip the DataFrame

By HowToSD·Created 2 years ago·Updated about a year ago· 23
SNS Scatter Plot Pt
  • tens
  • IMAGE
x_axis_dim0
y_axis_dims
title
x_axis_label
y_axis_label
legend_label
x_tick_as_intfalse
style
palette

SNS Scatter Plot Pt is the tensor-fed version of SNS Scatter Plot: take a rank-2 PyTorch tensor, pick which column is x and which are y, and get a Seaborn scatter back as an image. It's for when your data is already shaped as tensors - say, feature arrays out of a model or a companion wrapper node - and converting to a DataFrame just to plot feels like busywork. If that's not your situation, the DataFrame version is the friendlier one, because it can validate column names for you. This one can't; there are no names, only indices.

The inputs that matter

  • tens - rank-2 only; rows are observations, columns are features. A rank-3 tensor gets you Only rank 2 tensors are supported.
  • x_axis_dim - the column index for x, default 0.
  • y_axis_dims - column indices for y, as a string: 1 for one series, 1,2 for two scatter series on the same axes (parsed via ast.literal_eval).
  • legend_label - comma-separated labels matching your y dims. More labels than dims raises an error; fewer just blanks the rest.
  • title, x_axis_label, y_axis_label, x_tick_as_int, style, palette - the standard label and theming fields, same names as the rest of the pack.

Output is an IMAGE: the chart rendered to a PNG, normalized to a float tensor, ready for Save Image or a preview node.

How it works

For each y dim it pulls tens[:, x_axis_dim] and tens[:, y_axes[i]], moves them to CPU with .detach().cpu().numpy(), and calls sns.scatterplot on a shared axes - multiple y dims become multiple colored series, which is your cheap way to fake a grouping when the tensor has no categorical column. Then it renders the figure to an image tensor. Mechanically it's identical to SNS Line Plot Pt with a different Seaborn function, so once you've used one you've used both.

The Pt caveat

This node ships in ComfyUI-Data-Analysis, but the author's March 2025 update moved the PyTorch wrapper nodes - the ones that produce TENSOR data - into the separate ComfyUI-Pt-Wrapper extension. If you're plotting tensors you didn't build yourself, that companion is where the data side lives. Install it alongside.

Installing it

ComfyUI Manager → search "Data analysis" → install 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 (hardcoded folder name). No GPU needed; the pack needs pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl and lxml via pip - Manager does it, or pip install -r requirements.txt.

Troubleshooting

Same two traps as the other Pt nodes: wrong tensor rank, and legend labels outnumbering your y dims. Since there are no column names to check, a wrong index won't error - it'll just plot a different feature than you meant. Verify your tensor's shape (and which column is which) before you wire it up, or you'll spend ten minutes wondering why the scatter looks nothing like your data.

CategoryData Analysis

Inputs (10)

NameTypeDefaultDescription
tensTENSOR
x_axis_dimINT0-100–1000000
y_axis_dimsSTRING
titleSTRING
x_axis_labelSTRING
y_axis_labelSTRING
legend_labelSTRING
x_tick_as_intBOOLEANfalse
styleSTRING
paletteSTRING

Outputs (1)

NameTypeDescription
IMAGEIMAGE