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

SNS Line Plot Pt

Line plots straight from a tensor, when you're already in tensor land

By HowToSD·Created 2 years ago·Updated about a year ago· 23
SNS Line 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 Line Plot Pt is the PyTorch twin of SNS Line Plot: same idea, but it draws from a TENSOR instead of a pandas DataFrame. If your data lives in tensor form and you'd rather not round-trip it through a DataFrame just to get a chart, this is the node. It's also the plotting layer you'd pair with the tensor-producing nodes in the companion ComfyUI-Pt-Wrapper extension - anything you've shaped into a rank-2 tensor, you can plot without converting.

The inputs that matter

  • tens - a rank-2 tensor, rows as observations and columns as features. Anything else throws Only rank 2 tensors are supported.
  • x_axis_dim - which column index becomes the x-axis. Default 0, so your first column is assumed to be the independent variable.
  • y_axis_dims - which column indices become lines, as a string. 1 plots one line; 1,2 plots two series on the same axes. The field is parsed with ast.literal_eval, so a bare 1 or 1,2 both work.
  • legend_label - comma-separated labels matching your y dims. Give it more labels than y dims and it errors rather than guessing; fewer just leaves the rest blank.
  • x_tick_as_int, title, x_axis_label, y_axis_label, style, palette - the same polish knobs as the DataFrame version.

Output is an IMAGE - the plot rendered to a PNG and normalized to a float tensor, ready for Save Image or any preview node.

How it works

The node reads tens[:, x_axis_dim] and tens[:, y_axes[i]] for each y dim, moves them off the GPU with .detach().cpu().numpy(), and hands them to sns.lineplot on a shared matplotlib axes - so all your series land on one plot. Then it renders the figure to an image tensor, same as every SNS node in the pack. Nothing fancy, which is the point: it's a straight line from tensor to chart with no intermediate data structure.

The Pt caveat

These "Pt" plot nodes still live in ComfyUI-Data-Analysis, but the author's March 2025 update split the PyTorch wrapper nodes - the ones that actually produce TENSOR data from your pipeline or from image pixels - into the separate ComfyUI-Pt-Wrapper extension. The two packs are meant to work together: this one draws, that one feeds. If you can't find a source of tensors, that's why - install the companion.

Installing it

Standard pack install: 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 example workflows won't load. No GPU needed, but expect the pip dependencies - pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml - that stock ComfyUI doesn't ship. Manager handles them; by hand it's pip install -r requirements.txt.

Troubleshooting

The two errors you'll actually meet: a rank error because you fed a 1-D or 3-D tensor (unsqueeze or squeeze it first), and "More labels were specified than y-axis indices" from over-eager legend entries. And if the node seems missing entirely, seaborn probably never got installed - that's the number one cause of a blank custom node menu with this pack.

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