# Python Visuals

Python visual creation and matplotlib/seaborn patterns for PBIR reports.

- Repository: https://github.com/data-goblin/power-bi-agentic-development (1079 stars)
- Category: Writing
- License: GPL-3.0
- Last updated: 2026-10-30
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add data-goblin/power-bi-agentic-development --skill python-visuals -g -a claude-code -y`
Codex: `npx skills add data-goblin/power-bi-agentic-development --skill python-visuals -g -a codex -y`
Cursor: `npx skills add data-goblin/power-bi-agentic-development --skill python-visuals -g -a cursor -y`
Gemini CLI: `npx skills add data-goblin/power-bi-agentic-development --skill python-visuals -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add data-goblin/power-bi-agentic-development`

## Description

Python visual creation and matplotlib/seaborn patterns for PBIR reports. Automatically invoke when the user mentions "Python visual", "matplotlib in Power BI", "seaborn in Power BI", "pythonVisual", or asks to "create a Python visual", "add a matplotlib chart", "write a Python visual script".

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Python Visuals in Power BI (PBIR)

> **Use `pbir` for every report mutation.** Read PBIR metadata only for diagnosis. If `pbir` is
> unavailable or lacks an operation, stop and report the gap; never edit report JSON directly.

Python visuals execute matplotlib/seaborn scripts to render static PNG images on the Power BI canvas. **Prefer seaborn** over raw matplotlib for cleaner syntax and better defaults -- it handles most chart types with less code.

## Visual Identity

- **visualType:** `pythonVisual`
- **Data role:** `Values` (columns and measures, multiple allowed)
- **Data variable:** `dataset` (pandas DataFrame, auto-injected)
- **Row limit:** 150,000 rows
- **Output:** Static PNG at 72 DPI -- no interactivity

## Workflow: Creating a Python Visual

### Step 1: Add the Visual

```bash
pbir add visual pythonVisual "Report.Report/Page.Page" --name PythonChart \
  --data "Values:Sales.Date" --data "Values:Sales.Revenue"
```

### Step 2: Write the Script

```python
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(8, 4))
ax.bar(dataset["Date"], dataset["Sales"], color="#5B8DBE")
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
plt.tight_layout()
plt.show()  # MANDATORY
```

Critical rules:
- `plt.show()` is **mandatory** as the final line -- nothing renders without it
- `dataset` is auto-injected as a pandas DataFrame; do not create it
- Column names match the `nativeQueryRef` (display name) from field bindings
- Only the last `plt.show()` call renders; multiple figures not supported

### Step 2b: Review

Before presenting the script to the user, dispatch the `python-reviewer` agent to validate correctness and provide design feedback.

### Step 3: Inject the Script

```bash
pbir visuals python "Report.Report/Page.Page/PythonChart.Visual" \
  --script-file chart.py
```

The CLI handles PBIR string escaping.

### Step 4: Validate

The rest: https://github.com/data-goblin/power-bi-agentic-development/blob/HEAD/plugins/custom-visuals/skills/python-visuals/SKILL.md
