# Chart Generator

> Use this skill when asked to create a chart, graph, plot, or data visualization from data. Triggers: 'make a chart from this', 'plot this data', 'visualize this CSV', 'create a bar/line/pie chart', 'show me a graph of...', 'generate a dashboard'. Outputs publication-quality PNG/HTML charts.

- **Type:** Skill
- **Install:** `agentstack add skill-prasad-nimbalkar-claude-agent-skills-chart-generator`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [prasad-nimbalkar](https://agentstack.voostack.com/s/prasad-nimbalkar)
- **Installs:** 0
- **Category:** [Data & Analytics](https://agentstack.voostack.com/c/data-and-analytics)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [prasad-nimbalkar](https://github.com/prasad-nimbalkar)
- **Source:** https://github.com/prasad-nimbalkar/claude-agent-skills/tree/main/skills/chart-generator

## Install

```sh
agentstack add skill-prasad-nimbalkar-claude-agent-skills-chart-generator
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Chart Generator

## Why this skill exists

Choosing the wrong chart type is the most common data visualization mistake. This skill picks the right chart for the data shape and produces clean, labeled, publication-quality output — not matplotlib defaults.

## When to use

- User has data (CSV, JSON, or described) and wants it visualized
- User requests a specific chart type
- User wants to generate charts for a report or presentation

## Step-by-step procedure

### Step 1 — Pick the right chart type

| Data shape | Best chart |
|---|---|
| One number over time | Line chart |
| Comparing categories | Bar chart (vertical) or horizontal bar |
| Part-of-whole ( 5 slices — use a bar chart instead.**
**Never use 3D charts — they distort perception.**

### Step 2 — Load data

```python
import pandas as pd
import json

# From CSV
df = pd.read_csv("/mnt/user-data/uploads/data.csv")

# From JSON
with open("/mnt/user-data/uploads/data.json") as f:
    data = json.load(f)
df = pd.DataFrame(data)

# From user-described data (build inline)
df = pd.DataFrame({
    "Month": ["Jan", "Feb", "Mar", "Apr", "May"],
    "Revenue": [12000, 15000, 13500, 18000, 21000],
})
```

### Step 3 — Generate charts

**Bar chart:**
```python
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker

fig, ax = plt.subplots(figsize=(10, 6))
bars = ax.bar(df["Category"], df["Value"], color="#4F86C6", edgecolor="white", linewidth=0.5)

# Labels on bars
for bar in bars:
    height = bar.get_height()
    ax.text(bar.get_x() + bar.get_width()/2, height + 0.5,
            f"{height:,.0f}", ha="center", va="bottom", fontsize=10)

ax.set_title("Category Comparison", fontsize=16, fontweight="bold", pad=15)
ax.set_xlabel("Category", fontsize=12)
ax.set_ylabel("Value", fontsize=12)
ax.yaxis.set_major_formatter(mticker.FuncFormatter(lambda x, _: f"{x:,.0f}"))
ax.spines[["top", "right"]].set_visible(False)
ax.set_facecolor("#fafafa")
fig.tight_layout()
plt.savefig("/mnt/user-data/outputs/bar_chart.png", dpi=150, bbox_inches="tight")
plt.close()
```

**Line chart (time series):**
```python
fig, ax = plt.subplots(figsize=(12, 6))
ax.plot(df["Date"], df["Value"], color="#2E86AB", linewidth=2.5, marker="o", markersize=5)
ax.fill_between(df["Date"], df["Value"], alpha=0.1, color="#2E86AB")

ax.set_title("Trend Over Time", fontsize=16, fontweight="bold", pad=15)
ax.set_xlabel("Date", fontsize=12)
ax.set_ylabel("Value", fontsize=12)
ax.spines[["top", "right"]].set_visible(False)
plt.xticks(rotation=45)
fig.tight_layout()
plt.savefig("/mnt/user-data/outputs/line_chart.png", dpi=150, bbox_inches="tight")
plt.close()
```

**Scatter plot:**
```python
fig, ax = plt.subplots(figsize=(9, 7))
scatter = ax.scatter(df["x"], df["y"], c=df.get("group", "#4F86C6"),
                     alpha=0.7, s=60, edgecolors="white", linewidth=0.5)

ax.set_title("Correlation Analysis", fontsize=16, fontweight="bold", pad=15)
ax.set_xlabel("X Variable", fontsize=12)
ax.set_ylabel("Y Variable", fontsize=12)
ax.spines[["top", "right"]].set_visible(False)
fig.tight_layout()
plt.savefig("/mnt/user-data/outputs/scatter.png", dpi=150, bbox_inches="tight")
plt.close()
```

**Heatmap (correlation matrix):**
```python
import seaborn as sns

corr = df.select_dtypes(include="number").corr()
fig, ax = plt.subplots(figsize=(10, 8))
sns.heatmap(corr, annot=True, fmt=".2f", cmap="RdYlGn",
            center=0, linewidths=0.5, ax=ax,
            annot_kws={"size": 10})
ax.set_title("Correlation Matrix", fontsize=16, fontweight="bold", pad=15)
fig.tight_layout()
plt.savefig("/mnt/user-data/outputs/heatmap.png", dpi=150, bbox_inches="tight")
plt.close()
```

**Interactive chart with Plotly (HTML output):**
```python
import plotly.express as px

fig = px.bar(df, x="Category", y="Value", color="Group",
             title="Interactive Bar Chart",
             template="plotly_white",
             color_discrete_sequence=px.colors.qualitative.Set2)

fig.update_layout(font_family="Arial", title_font_size=18)
fig.write_html("/mnt/user-data/outputs/chart.html")
print("Interactive chart saved as HTML")
```

### Step 4 — Multi-chart dashboard

```python
fig, axes = plt.subplots(2, 2, figsize=(14, 10))
fig.suptitle("Data Dashboard", fontsize=18, fontweight="bold", y=1.02)

# Add each chart to a subplot
# axes[0][0] = chart 1, axes[0][1] = chart 2, etc.

plt.tight_layout()
plt.savefig("/mnt/user-data/outputs/dashboard.png", dpi=150, bbox_inches="tight")
```

## Edge cases

| Situation | Fix |
|-----------|-----|
| Dates not parsed | `pd.to_datetime(df["date"])` |
| Too many categories (> 15) | Use horizontal bar + show top N + "Other" |
| Negative values in bar chart | Set `ax.axhline(0, color="black", linewidth=0.8)` |
| Very different scales | Use dual Y-axis with `ax.twinx()` |
| Missing values in time series | `df.interpolate()` or show gaps explicitly |
| Matplotlib not installed | `pip install matplotlib seaborn plotly --break-system-packages` |

## Output format

Always report:
- Chart type chosen and why
- X/Y axes and what they represent
- Output file path(s)
- Key insight from the chart (1 sentence: "Revenue peaks in Q4 with $21k")

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [prasad-nimbalkar](https://github.com/prasad-nimbalkar)
- **Source:** [prasad-nimbalkar/claude-agent-skills](https://github.com/prasad-nimbalkar/claude-agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-prasad-nimbalkar-claude-agent-skills-chart-generator
- Seller: https://agentstack.voostack.com/s/prasad-nimbalkar
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
