matplotlib
Skill15 starsChanged 42 days agoMITView on GitHub
Expert Matplotlib visualization assistance covering figure subplots, custom styling, colormaps, and publication-ready charts. Use when creating static or publication scientific figures in Python.
19 other projects use a version of this.
Adopted by
Most recently taken up by
- holtzy/dataviz-skillstheir own version, first seen Nov 8, 2026
- BrightGold70/skillstheir own version, first seen Nov 8, 2026
- MarieLynneBlock/arcanum-artifextheir own version, first seen Nov 1, 2026
- davidanthonyn/claude-skillstheir own version, first seen Oct 20, 2026
- patoangolano/bio-stacktheir own version, first seen Oct 15, 2026
- Luooops/skillstheir own version, first seen Oct 13, 2026
Used with
Projects with it also use usfiscaldata, deeptools and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
yf8578Skillusfiscaldata
Query the U.S. Treasury Fiscal Data API for federal financial data including national debt, government spending, revenue, interest rates, exchange rates, and savings bonds. Access 54 datasets and 182 data tables with no API key required. Use when working with U.S. federal fiscal data, national debt tracking (Debt to the Penny), Daily Treasury Statements, Monthly Treasury Statements, Treasury securities auctions, interest rates on Treasury securities, foreign exchange rates, savings bonds, or any U.S. government financial statistics.
Also in 7 projects that use this
garri333Skilldeeptools
NGS analysis toolkit. BAM to bigWig conversion, QC (correlation, PCA, fingerprints), heatmaps/profiles (TSS, peaks), for ChIP-seq, RNA-seq, ATAC-seq visualization.
Also in 10 projects that use this
garri333Skilldnanexus-integration
DNAnexus cloud genomics platform. Build apps/applets, manage data (upload/download), dxpy Python SDK, run workflows, FASTQ/BAM/VCF, for genomics pipeline development and execution.
Also in 10 projects that use this
- +9 more from garri333
Other versions19 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 19
- wu-yc/LabClaw★ 1.1ksame name
- LeonChaoX/qinyan-academic-skills★ 910same name
- xenodium/emacs-skills★ 142same name
- qinyan-ai/qinyan-academic-skills★ 80same name
- Barrios88/barrios-skills★ 63same name
- tvhahn/matplotlib-skill★ 38same name
- tondevrel/scientific-agent-skills★ 22same name
- holtzy/dataviz-skills★ 16same name
- hxhx-win/zhuanli-flow★ 4same name
- MarieLynneBlock/arcanum-artifex★ 4same name
9 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository350 other files it gives its agents.
- airflowSkill
- catboostSkill
- claudeSkill
- comfyuiSkill
- cursor-aiSkill
- dalleSkill
- daskSkill
- dbtSkill
- deepseekSkill
- fastaiSkill
- geminiSkill
- github-copilotSkill
- huggingfaceSkill
- jaxSkill
- jupyterSkill
- kerasSkill
- langchainSkill
- lightgbmSkill
- llamaindexSkill
- llamaSkill
- midjourneySkill
- mistralSkill
- mlflowSkill
- nltkSkill
- numpySkill
- ollamaSkill
- openai-gptSkill
- opencvSkill
- pandasSkill
- perplexitySkill
- plotlySkill
- polarsSkill
- pytorchSkill
- raySkill
- scikit-learnSkill
- seabornSkill
- spacySkill
- sparkSkill
- stable-diffusionSkill
- tensorflowSkill
- vaexSkill
- weights-biasesSkill
- whisperSkill
- xgboostSkill
- api-gatewaySkill
- clean-architectureSkill
- cqrsSkill
- domain-driven-designSkill
- event-drivenSkill
- event-sourcingSkill
- graphqlSkill
- grpcSkill
- hexagonalSkill
- microservicesSkill
- modular-monolithSkill
- monolithSkill
- rest-apiSkill
- sagaSkill
- serverlessSkill
- service-meshSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 0 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 19 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 136
Use plt.subplots with shared axes:
- Very specific: line 155
Use the Object-Oriented interface (fig, ax = plt.subplots()) instead of stateful plt.plot() calls.
- Very specific: line 157
Always call plt.close(fig) after saving to disk to prevent memory leaks from accumulated figures.
- Very specific: line 162
Use rainbow/jet colormaps.
- Very specific: line 164
Leave gridlines enabled on both axes when using twinx().
“Common” is measured: kept by at least 6 in 10 of the 19 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Matplotlib
Matplotlib is the grandfather of Python plotting. It is verbose but provides infinite control.
When to Use
- Publication-Quality Scientific Plotting: Generating exact, reproducible figures for academic papers, documentation, and reports.
- Fine-Grained Custom Visualizations: Complete control over every pixel, tick, axis spine, legend, and colorbar.
- Headless Server-Side Chart Rendering: Generating PNG, SVG, and PDF visualizations in backend microservices without GUI displays.
- Subplot Grid Layouts: Assembling multi-panel visual figure grids with
GridSpec.
Quick Start
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
fig, ax = plt.subplots(figsize=(8, 4), dpi=100)
ax.plot(x, y1, label="sin(x)", color="#2563eb", linewidth=2)
ax.plot(x, y2, label="cos(x)", color="#dc2626", linestyle="--")
ax.set_title("Trigonometric Functions")
ax.set_xlabel("Time (s)")
ax.set_ylabel("Amplitude")
ax.legend()
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()Core Concepts
Object-Oriented Subplots & Modern Styling
Building clean, publication-ready multi-axis figures:
import matplotlib.pyplot as plt
import numpy as np
# Use non-interactive backend for server environments
import matplotlib
matplotlib.use('Agg')
# Set modern styling parameters
plt.style.use('seaborn-v0_8-whitegrid' if 'seaborn-v0_8-whitegrid' in plt.style.available else 'default')
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5), dpi=300)
x = np.linspace(0, 10, 200)
y1 = np.sin(x) * np.exp(-0.1 * x)
y2 = np.cos(x) * np.exp(-0.1 * x)
# Panel 1: Line plot with error bands
ax1.plot(x, y1, color='#2563eb', lw=2, label='Damped Sine')
ax1.fill_between(x, y1 - 0.2, y1 + 0.2, color='#2563eb', alpha=0.15)
ax1.set_title("Signal Decay", fontsize=12, fontweight='bold')
ax1.set_xlabel("Time (seconds)")
ax1.set_ylabel("Amplitude")
ax1.legend(loc='upper right')
# Panel 2: Distribution histogram
data = np.random.normal(loc=0, scale=1, size=1000)
ax2.hist(data, bins=30, color='#10b981', edgecolor='white', alpha=0.85)
ax2.set_title("Residual Distribution", fontsize=12, fontweight='bold')
ax2.set_xlabel("Value")
ax2.set_ylabel("Frequency")
plt.tight_layout()
fig.savefig("metrics_figure.png", dpi=300, bbox_inches='tight')
plt.close(fig)Secondary Twin Axis (twinx)
Plotting two metrics with different scales on the same chart:
fig, ax1 = plt.subplots(figsize=(8, 4.5))
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
revenue = [120, 145, 160, 190, 210, 250]
churn_rate = [2.4, 2.1, 1.9, 1.8, 1.5, 1.2]
# Primary axis: Bar chart
bars = ax1.bar(months, revenue, color='#4f46e5', alpha=0.7, width=0.5, label='Revenue ($k)')
ax1.set_ylabel('Revenue in Thousands ($)', color='#4f46e5')
ax1.tick_params(axis='y', labelcolor='#4f46e5')
# Secondary axis: Line plot
ax2 = ax1.twinx()
line = ax2.plot(months, churn_rate, color='#ef4444', lw=3, marker='o', label='Churn Rate (%)')
ax2.set_ylabel('Churn Rate (%)', color='#ef4444')
ax2.tick_params(axis='y', labelcolor='#ef4444')
ax2.grid(False) # Prevent overlapping grid lines
plt.title("Revenue Growth vs. Churn Reduction (2026)")
plt.savefig("revenue_churn.png", bbox_inches='tight')
plt.close(fig)Heatmaps & Custom Colormaps
Visualizing correlation matrices or loss surfaces:
matrix = np.corrcoef(np.random.randn(8, 100))
fig, ax = plt.subplots(figsize=(6, 5))
cax = ax.matshow(matrix, cmap='coolwarm', vmin=-1, vmax=1)
fig.colorbar(cax)
ax.set_xticks(range(8))
ax.set_yticks(range(8))
ax.set_title("Correlation Heatmap", pad=20)
plt.savefig("heatmap.png", bbox_inches='tight')
plt.close(fig)Common Patterns
Clean Multi-Panel Subplots with Shared Axes
Problem: Creating multiple comparative charts where axis ranges must stay aligned.
Solution:
Use plt.subplots with shared axes:
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 6), sharex=True)
ax1.plot(x, y1, color="navy")
ax1.set_ylabel("Raw Signal")
ax2.plot(x, np.abs(y1), color="darkorange")
ax2.set_ylabel("Rectified")
ax2.set_xlabel("Sample")
plt.tight_layout()Best Practices
Do:
- Use the Object-Oriented interface (
fig, ax = plt.subplots()) instead of statefulplt.plot()calls. - Set
matplotlib.use('Agg')when running inside serverless functions, Docker, or CI without a desktop display. - Always call
plt.close(fig)after saving to disk to prevent memory leaks from accumulated figures. - Save figures with
bbox_inches='tight'to prevent labels and titles from being clipped at margins.
Don't:
- Use rainbow/jet colormaps; use perceptively uniform colormaps (
viridis,plasma,coolwarm). - Rely on default DPI (100); export publication graphics with at least
dpi=300. - Leave gridlines enabled on both axes when using
twinx(); disable one to prevent clutter.
Troubleshooting
| Error | Cause | Solution |
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend | Attempting plt.show() in headless server/container. | Save figure to disk instead: fig.savefig('output.png'). |
Labels overlapping or cut off | Figure bounding box too tight for tick labels. | Call plt.tight_layout() or use bbox_inches='tight' when saving. |
Memory leak: Figures not closing | Creating figures in loops without calling plt.close(). | Add plt.close(fig) at the end of each loop iteration. |
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

