Skip to content

Commit 53e5a55

Browse files
Merge pull request #104 from MarcSkovMadsen/feature/update-matplotlib-docs
docs: enhance matplotlib backend guidance in panel skills
2 parents fd1b11d + aacff87 commit 53e5a55

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

.github/agents/holoviz-analysis-planner.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: HoloViz Analysis Planner
33
description: Create a detailed implementation plan for an analysis or data visualization using the HoloViz ecosystem without modifying code
4-
tools: ['holoviz-dev/*', 'read/readFile', 'read/problems', 'agent/runSubagent', 'web/fetch', 'web/githubRepo', 'search/codebase', 'search/usages', 'search/searchResults', 'vscode/vscodeAPI']
4+
tools: ['holoviz/*', 'read/readFile', 'read/problems', 'agent/runSubagent', 'web/fetch', 'web/githubRepo', 'search/codebase', 'search/usages', 'search/searchResults', 'vscode/vscodeAPI']
55
handoffs:
66
- label: Implement Plan
77
agent: agent

src/holoviz_mcp/config/resources/skills/panel.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,33 @@ def kpi_value(self):
537537

538538
DO follow the hvplot and holoviews best practice guides!
539539

540+
### Matplotlib
541+
542+
**CRITICAL**: On windows set non-interactive backend before importing matplotlib.pyplot:
543+
544+
**Why**: The `'agg'` backend is required for server-side rendering without display. Panel needs to render plots as images, not interactive GUI windows.
545+
546+
**Extension**: DON'T include `'matplotlib'` in `pn.extension()` - it doesn't require JavaScript loading like Plotly or Bokeh extensions.
547+
548+
```python
549+
# ✅ CORRECT
550+
import matplotlib
551+
matplotlib.use('agg')
552+
import matplotlib.pyplot as plt
553+
import panel as pn
554+
555+
pn.extension() # No 'matplotlib' needed
556+
557+
# ❌ WRONG
558+
pn.extension('matplotlib') # Not a Panel extension
559+
```
560+
561+
**Best Practices**:
562+
563+
- DO use matplotlib for publication-quality static plots
564+
- DO close figures after rendering to prevent memory leaks: `plt.close(fig)`
565+
- DO consider hvPlot or Plotly for interactive plots instead
566+
540567
### Plotly
541568

542569
Do set the template (theme) depending on the `theme` of the app.

0 commit comments

Comments
 (0)