ComfyUI Node

SNS Heatmap

This Heatmap Is Really a Correlation Matrix

By HowToSD·Created 2 years ago·Updated about a year ago· 23
SNS Heatmap
  • dataframe
  • IMAGE
title
palette

Here's the thing the name doesn't tell you: SNS Heatmap doesn't plot your data's raw values. It computes the correlation matrix first, then draws that as an annotated heatmap. Feed it a DataFrame of numeric columns and you get the correlation of every column with every other column, with the numbers printed right in the cells.

That's arguably more useful than a plain heatmap, and it's definitely the node to reach for when someone asks "which of my columns are actually related?" - the whole point of a correlation analysis.

How it works

Under the hood it calls dataframe.corr() and hands the result to Seaborn's heatmap with annotations on. So the rows and columns of the chart are your numeric columns, and each cell is the Pearson correlation between the pair - a value between -1 and 1. Diagonal cells are 1.0 (a column correlates perfectly with itself), and the rest tell you how closely columns move together. Because it's correlation, your input should be numeric; text columns are ignored or break the computation depending on your data.

There's no style input here (only title and palette), because the pack's normal style setup doesn't play nice with heatmaps. The palette string maps to a Seaborn colormap via sns.color_palette(palette, as_cmap=True) - names like "coolwarm" or "viridis" work. Output is an IMAGE tensor like the other SNS nodes.

Inputs and outputs

  • dataframe - your numeric data.
  • title - chart title.
  • palette - Seaborn colormap name for the heat gradient.

Output: one IMAGE.

Install

Part of HowToSD/ComfyUI-Data-Analysis. Manager: search "Data analysis" in the Custom Node Manager, install, restart, reload the browser. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis   # README: example workflows rely on this folder name
pip install -r requirements.txt

Needs seaborn and matplotlib; no models, no GPU.

Common issues

The big one is expectation management: if you loaded a table of raw values expecting the cells to show those values, you'll be confused - this node always plots correlation. For a raw-value heatmap you'd want a different tool. Also, a wide DataFrame with mostly text or missing values will produce a sparse, mostly-empty correlation matrix; corr() drops non-numeric columns, so feed it the numeric slice. And if your palette name isn't a valid Seaborn colormap, it errors at runtime. If you want the raw correlation numbers as data rather than a picture, the pack has a Pandas Corr node too - the heatmap is the visual of that same computation.

CategoryData Analysis

Inputs (3)

NameTypeDefaultDescription
dataframeDATAFRAME
titleSTRING
paletteSTRING

Outputs (1)

NameTypeDescription
IMAGEIMAGE