MPL Bar Chart
Get a real bar chart out of a DataFrame and into your workflow
- dataframe
- IMAGE
MPL Bar Chart is where the Data-Analysis pack finally pays off visually: feed it a DataFrame, point it at an x column and a y column, and it hands you a Matplotlib bar chart as a proper ComfyUI IMAGE - ready for Preview Image, Save Image, or even a VAE encode if you're feeling weird. It's the answer to "I did all this Pandas work in a node graph, now where's my chart?"
It's one of four MPL plot nodes in HowToSD's ComfyUI-Data-Analysis pack (the others: MPL Line, MPL Scatter, MPL Pie Chart). Same author, same philosophy as the README's flagship example - figuring out which MLB player had the most hits per year from a stats CSV - where the payoff is a chart you can actually see.
How it works
Under the hood it's a thin wrapper: the node looks up your two columns in the DataFrame, calls ax.bar(df[x_column], df[y_column]), then runs a shared post-step that sets the title and axis labels, saves the figure to a PNG buffer, converts it to RGB, and normalizes it into a [0,1] tensor with a batch dimension - i.e., a standard ComfyUI IMAGE. The figure is closed after rendering so memory doesn't leak across runs.
A nice implementation detail: column names you type are resolved against the actual DataFrame via column_label_string_to_target_type, so a numeric column label typed as a string still resolves correctly. And the x_tick_as_int toggle uses Matplotlib's MaxNLocator(integer=True) - that's the fix for year axes that render as 2002.5 when pandas stored years as floats.
Inputs and outputs
- dataframe (required,
DATAFRAME) - your data. Loaded, created, or transformed anywhere in the pack. - x_column_name / y_column_name (required,
STRING) - the columns for the axis. - title, x_axis_label, y_axis_label (required,
STRING, default empty) - leave blank for a bare chart or fill for a presentable one. - x_tick_as_int (required,
BOOLEAN, default false) - force integer x ticks when floats sneak in. - IMAGE output - wire into Preview Image or Save Image.
When you'd reach for it
Any time you want a quick categorical comparison from tabular data: totals per group, counts per category, the hits-per-player question from the README. It slots naturally after Pandas Group By or Pandas Value Counts - aggregate first, plot the summary. If your data is a time series, MPL Line is usually the better read; bar charts shine on discrete categories.
Installing it
Pack install, once. ComfyUI Manager: search "Data analysis", install ComfyUI-Data-Analysis, restart, reload. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis
mv ComfyUI-Data-Analysis data-analysis # README: examples depend on this folder name
pip install -r data-analysis/requirements.txt
Dependencies: pandas, matplotlib (non-negotiable here), seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU required for the plot itself - rendering is CPU-side Matplotlib. Since March 2025 the PyTorch nodes moved to ComfyUI-Pt-Wrapper.
Gotchas
- Column names must match exactly. A typo raises a KeyError at execution. Wire from Pandas Columns → a show node if you're unsure of the names.
- Bad data → bad chart. NaNs create gaps; run Pandas Fill NA or Drop NA first.
- Labels are optional but charts look like sketches without them. One
titlestring makes the output worth keeping.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| x_column_name | STRING | — | |
| y_column_name | STRING | — | |
| title | STRING | — | |
| x_axis_label | STRING | — | |
| y_axis_label | STRING | — | |
| x_tick_as_int | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |