Generate charts from tabular data via the bundled scripts/charts.py toolkit.
Each function takes a DataFrame or a file path plus the columns to plot, and
saves a PNG (returning the path). It handles theming, figure sizing, label
rotation, NaN dropping, legend placement, and saving.
Instructions
- Provide the data source: a pandas DataFrame, or a path to a
.csv / .tsv /
.json file.
- Call the function for the chart you need, passing the column names:
bar(data, x, y) — one value per category (horizontal=True for barh)
grouped_bar(data, x, y, group) — value per category split by group
(stacked=True to stack)
line(data, x, y, group=None) — value over an ordered axis, one line per
group
scatter(data, x, y, group=None, size=None) — two numeric columns
histogram(data, y, bins=20, group=None) — distribution of one column
pie(data, x, y, donut=False) — share of y per category x
- Optional keyword args on every chart:
title, xlabel, ylabel (derived
from column names if omitted), out (default "chart.png"; pass None to
skip saving), dpi (default 150), figsize, palette.
- The function returns the saved image path. See
references/cheatsheet.md for
full signatures and a chart-selection table.
Usage
Import:
from charts import bar, line, pie
bar("sales.csv", x="region", y="revenue", title="Revenue by region",
out="revenue.png")
CLI:
python scripts/charts.py grouped_bar sales.csv \
--x region --y revenue --group quarter --stacked --out by_quarter.png
Bundled files
scripts/charts.py — the toolkit: load_data, apply_theme, save_fig, and
six chart functions (bar, grouped_bar, line, scatter, histogram,
pie), plus a CLI. Depends on matplotlib and pandas; runs headless.
references/cheatsheet.md — chart-selection table, full signatures, and
copy-paste CLI examples.
assets/sample_sales.csv — a small demo dataset that exercises every chart.
Defaults
- Colorblind-friendly palette and a shared theme across charts.
- Figure size, x-label rotation, and legend placement adapt to the data.
- Rows with missing values in the plotted columns are dropped before drawing.
- Output is a saved PNG at 150 DPI by default (override
out and dpi).
1---2name: chart-builder3description: Use this skill whenever the user asks to visualize, chart, plot, or graph data (bar, line, scatter, histogram, pie) from a CSV, table, or DataFrame. It gives the agent prebuilt, parameterized matplotlib functions so charts are produced faster and more reliably — with consistent styling and sane defaults — instead of hand-writing matplotlib each time.4---56Generate charts from tabular data via the bundled `scripts/charts.py` toolkit.7Each function takes a DataFrame or a file path plus the columns to plot, and8saves a PNG (returning the path). It handles theming, figure sizing, label9rotation, NaN dropping, legend placement, and saving.1011## Instructions121. Provide the data source: a pandas DataFrame, or a path to a `.csv` / `.tsv` /13 `.json` file.142. Call the function for the chart you need, passing the column names:15 - `bar(data, x, y)` — one value per category (`horizontal=True` for barh)16 - `grouped_bar(data, x, y, group)` — value per category split by `group`17 (`stacked=True` to stack)18 - `line(data, x, y, group=None)` — value over an ordered axis, one line per19 `group`20 - `scatter(data, x, y, group=None, size=None)` — two numeric columns21 - `histogram(data, y, bins=20, group=None)` — distribution of one column22 - `pie(data, x, y, donut=False)` — share of `y` per category `x`233. Optional keyword args on every chart: `title`, `xlabel`, `ylabel` (derived24 from column names if omitted), `out` (default `"chart.png"`; pass `None` to25 skip saving), `dpi` (default `150`), `figsize`, `palette`.264. The function returns the saved image path. See `references/cheatsheet.md` for27 full signatures and a chart-selection table.2829## Usage30Import:31```python32from charts import bar, line, pie33bar("sales.csv", x="region", y="revenue", title="Revenue by region",34 out="revenue.png")35```3637CLI:38```bash39python scripts/charts.py grouped_bar sales.csv \40 --x region --y revenue --group quarter --stacked --out by_quarter.png41```4243## Bundled files44- `scripts/charts.py` — the toolkit: `load_data`, `apply_theme`, `save_fig`, and45 six chart functions (`bar`, `grouped_bar`, `line`, `scatter`, `histogram`,46 `pie`), plus a CLI. Depends on `matplotlib` and `pandas`; runs headless.47- `references/cheatsheet.md` — chart-selection table, full signatures, and48 copy-paste CLI examples.49- `assets/sample_sales.csv` — a small demo dataset that exercises every chart.5051## Defaults52- Colorblind-friendly palette and a shared theme across charts.53- Figure size, x-label rotation, and legend placement adapt to the data.54- Rows with missing values in the plotted columns are dropped before drawing.55- Output is a saved PNG at 150 DPI by default (override `out` and `dpi`).