MAGIC Agent Skills is now open source! Star on GitHub
MAGIC Agent SkillsMAGIC Agent Skills
TutorialsEasy

Create Basic Visualizations

A picture is worth a thousand rows. This tutorial shows how the agent interprets a plain-English request, selects appropriate chart types based on data characteristics, and generates publication-ready PNG files — no matplotlib boilerplate required.

You'll see the agent create three charts (a box plot, a bar chart, and a violin plot) from a single prompt, with reasoning shown at every decision point.

Setup

Follow these steps to set up your environment. If you've already installed, skip to the sample data.

Install the skills

npx @votee-ai/magic-data-agent-skills init

Create a workspace

mkdir magic-tutorial && cd magic-tutorial

Download sample data

curl -O https://docs.votee.ai/tutorials/data/product_metrics.csv

Sample Data

This tutorial uses a 300-row product metrics dataset with clean numeric and categorical columns. Download it to follow along:

The Agent Trace

The trace below shows how the agent reads the data, selects chart types based on column characteristics, writes a generation script, and verifies each chart visually.

magic-data-visualization3 minutes

Create visualizations showing the distribution of sales, profit margins, and customer ratings by category from data/product_metrics.csv. Save charts to a charts/ directory.

User prompt

00:00
magic-data-visualizationSkillvisualizationsdistributioncharts
00:04

Detected 'visualizations', 'distribution', 'charts' — the agent loads the visualization SKILL.md for chart selection heuristics, anti-patterns, and styling rules

data inspectionExecution
00:08

Input

{
  "file_path": "data/product_metrics.csv"
}

Output

{
  "rows": 300,
  "columns": 9,
  "categories": 8,
  "records_per_category": "29–54",
  "numeric_columns": [
    "sales",
    "profit_margin",
    "units_sold",
    "customer_rating",
    "return_rate"
  ]
}
import pandas as pd
df = pd.read_csv('data/product_metrics.csv')
print(df['category'].value_counts())
print(df.describe())
_make_charts.pyExecution
00:16

Input

{
  "charts": [
    {
      "type": "box plot",
      "metric": "sales",
      "groupby": "category"
    },
    {
      "type": "box plot",
      "metric": "profit_margin",
      "groupby": "category"
    },
    {
      "type": "box plot",
      "metric": "customer_rating",
      "groupby": "category"
    },
    {
      "type": "dashboard",
      "metrics": [
        "sales",
        "profit_margin",
        "customer_rating"
      ]
    }
  ],
  "output_dir": "charts/",
  "dpi": 300,
  "palette": "Okabe-Ito (colorblind-safe)"
}

Output

{
  "files_created": 4,
  "sales_by_category.png": "Box plot — sales distribution sorted by median, Y-axis floored at 0",
  "profit_margin_by_category.png": "Box plot — profit margin distribution",
  "customer_rating_by_category.png": "Box plot — customer rating distribution (1-5 scale)",
  "dashboard_by_category.png": "All three side-by-side for comparison"
}
import pandas as pd
import matplotlib.pyplot as plt
from pathlib import Path

df = pd.read_csv('data/product_metrics.csv')
OKABE_ITO = ['#E69F00','#56B4E9','#009E73',
  '#F0E442','#0072B2','#D55E00','#CC79A7','#000000']

def box_by_category(df, col, ylabel, title, path, y_floor_zero=False):
    cats = df.groupby('category')[col].median().sort_values().index
    data = [df[df['category']==c][col] for c in cats]
    bp = ax.boxplot(data, labels=cats, patch_artist=True)
    for patch, color in zip(bp['boxes'], OKABE_ITO):
        patch.set_facecolor(color)
charts/_make_charts.pyCheckpoint
00:22

charts/_make_charts.py

Chart generation script saved — can be re-run with `python3 charts/_make_charts.py` to regenerate all charts

output verificationExecution
00:25

Input

{
  "directory": "charts/"
}

Output

{
  "files_verified": 4,
  "resolution": "2970×1770 px (300 DPI)",
  "metadata_files": 3,
  "all_valid": true
}
ls -la charts/
Results deliveredOutput
00:28

Visualizations Complete

Generated 4 charts in charts/ from data/product_metrics.csv (300 rows, 8 categories):

  • `sales_by_category.png` — sales distribution (box plot, sorted by median)
  • `profit_margin_by_category.png` — profit margin distribution
  • `customer_rating_by_category.png` — customer rating distribution
  • `dashboard_by_category.png` — all three side-by-side
  • Box plots chosen since each category has 29-54 records — they show median, IQR, and outliers rather than collapsing to a single bar. Sidecar .meta.json saved alongside each chart. Colorblind-safe palette, 300 DPI.

    Artifacts

    sales_by_category.png

    Sales distribution box plots by category

    profit_margin_by_category.png

    Profit margin distribution box plots

    customer_rating_by_category.png

    Customer rating distribution box plots

    dashboard_by_category.png

    Combined dashboard — all three metrics

    _make_charts.py

    Reusable chart generation script

    Data Flow

    StepSkillInputOutputKey Config
    1magic-data-visualizationproduct_metrics.csv (300×9)4 PNG charts + 1 Python script in charts/palette: Okabe-Ito, DPI: 300

    Charts Generated

    The agent produced three charts — click to view full size:

    Sales by Category

    Box plots showing sales spread per category, sorted by median. Categories range from ~$400 to ~$600 median, with individual outliers above $900.

    Profit Margin by Category

    Box plots of profit margin distributions. Most categories cluster around 0.22–0.27, with visible spread in each.

    Customer Rating by Category

    Box plots of rating distributions (1–5 scale). All categories span roughly 2.1–5.0 with medians around 3.6–3.9.

    Dashboard — All Metrics

    Combined dashboard showing all three metrics side-by-side for easy comparison across categories.

    What Happened

    Data Inspection and Chart Type Selection

    The agent loaded product_metrics.csv (300 rows × 9 columns), inspected column types to determine which chart types are appropriate, and chose box plots for all three metrics because each category has 29–54 records — enough data points to show median, IQR, and outliers meaningfully. A bar chart would collapse each category to a single number, hiding the distribution the user asked for.

    Script Generation

    The agent wrote a complete _make_charts.py script following SKILL.md rules: Okabe-Ito colorblind-safe palette, no gridlines, top/right spines removed, categories sorted by median. It also generated sidecar .meta.json files and a combined dashboard.

    Output Verification

    The agent verified all chart files exist at 300 DPI (2970×1770 px) with metadata files — confirming the output matches the SKILL.md quality standards.

    Try It Yourself

    Copy this prompt with your own CSV:

    Create visualizations showing the distribution of sales, profit margins,
    and customer ratings by category from data/product_metrics.csv.
    Save charts to a charts/ directory.

    Want to be more specific? Try targeting individual metrics:

    Show me a box plot of revenue by region and a scatter plot of quantity vs price

    The agent accepts both broad intent ("visualizations") and precise column-level instructions.

    What You Learned

    • Intent mapping: "distribution" → box plots; "by category" → grouped comparisons. You don't need to name chart types explicitly.
    • The agent writes a reusable script (generate_charts.py) rather than throwaway commands, so you can regenerate or modify charts later.
    • Visual verification is built in — the agent reads each PNG to confirm the chart rendered correctly before reporting success.
    • Multiple charts are produced from one prompt, with consistent styling across all outputs.

    Alternate Approaches

    Next Steps

    Was this page helpful?
    Edit on GitHub

    Last updated on

    On this page