matplotlib-pro
Professional sub-skill for Matplotlib focused on high-performance animations, complex multi-figure layouts (GridSpec), interactive widgets, and publication-ready typography (LaTeX/PGF).
Best use case
matplotlib-pro is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Professional sub-skill for Matplotlib focused on high-performance animations, complex multi-figure layouts (GridSpec), interactive widgets, and publication-ready typography (LaTeX/PGF).
Teams using matplotlib-pro should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/matplotlib-pro/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How matplotlib-pro Compares
| Feature / Agent | matplotlib-pro | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Professional sub-skill for Matplotlib focused on high-performance animations, complex multi-figure layouts (GridSpec), interactive widgets, and publication-ready typography (LaTeX/PGF).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Matplotlib - Professional Viz & Animation
Beyond static plots, Matplotlib is a powerful engine for dynamic data visualization and scientific storytelling. This guide focuses on the "Pro" features: blitting for speed, Artist hierarchy for control, and LaTeX integration for papers.
## When to Use
- Creating high-FPS animations for simulations (Fluid dynamics, N-body).
- Building custom interactive tools inside Jupyter or a GUI.
- Generating pixel-perfect figures for academic journals.
- Visualizing real-time data streams from sensors.
## Core Principles
### 1. The Artist Hierarchy
Everything you see is an Artist. Figures contain Axes, Axes contain Lines, Text, Patches. Pro-level control means manipulating these objects directly instead of using high-level `plt` commands.
### 2. Blitting (The Secret to Speed)
Standard animation redraws the whole figure every frame (slow). Blitting only redraws the parts that changed (e.g., the moving line), while keeping the axes and labels cached as a background image.
### 3. Backend Mastery
- **Agg**: High-quality static PNGs.
- **PDF/PGF**: Vector-based for LaTeX.
- **TkAgg/QtAgg**: Interactive windows.
## High-Performance Animation
### Using FuncAnimation with Blitting
```python
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2) # Returns the Line2D artist
def init():
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1, 1)
return line, # Note the comma
def update(frame):
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x + frame/10.0)
line.set_data(x, y)
return line,
# blit=True is critical for performance
ani = FuncAnimation(fig, update, frames=100, init_func=init, blit=True)
plt.show()
```
## Publication Standards
### 1. LaTeX & PGF Backend (For Papers)
```python
import matplotlib as mpl
mpl.use("pgf") # Use PGF for perfect LaTeX integration
mpl.rcParams.update({
"pgf.texsystem": "pdflatex",
"font.family": "serif",
"text.usetex": True,
"pgf.rcfonts": False,
})
fig.savefig("figure.pgf") # Import this directly into your LaTeX doc
```
### 2. Complex GridSpec Layouts
```python
import matplotlib.gridspec as gridspec
fig = plt.figure(constrained_layout=True)
gs = gridspec.GridSpec(3, 3, figure=fig)
ax_main = fig.add_subplot(gs[0:2, :]) # Top 2/3rds
ax_hist_x = fig.add_subplot(gs[2, 0:2]) # Bottom left
ax_hist_y = fig.add_subplot(gs[2, 2]) # Bottom right
```
## Interactive Widgets
### Custom Sliders and Buttons
```python
from matplotlib.widgets import Slider
fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
line, = ax.plot(x, np.sin(x))
ax_freq = plt.axes([0.25, 0.1, 0.65, 0.03])
slider = Slider(ax_freq, 'Freq', 0.1, 30.0, valinit=1.0)
def update(val):
line.set_ydata(np.sin(slider.val * x))
fig.canvas.draw_idle() # Optimized redraw
slider.on_changed(update)
```
## Critical Rules
### ✅ DO
- **Use fig.canvas.draw_idle()** - It tells Matplotlib to redraw only when the event loop is free, preventing UI lag.
- **Vectorize Text** - Save as `.svg` or `.pdf` to ensure labels don't pixelate in reports.
- **Close your animations** - Use `plt.close()` to prevent memory leaks in notebooks.
- **Use ArtistAnimation** - If you already have all frames calculated as images, ArtistAnimation is faster than FuncAnimation.
### ❌ DON'T
- **Don't use plt.pause() in heavy loops** - It's inefficient; use the animation framework.
- **Don't hardcode "inches"** - Use `fig.get_size_inches()` and scale relative to the figure size for portability.
- **Don't ignore Tight Layout** - Overlapping subplots are a common "amateur" mistake. Use `fig.set_constrained_layout(True)`.
Matplotlib Pro is the bridge between data and insight. Mastering the blitting engine and the PGF backend allows scientists to create dynamic evidence that is as visually compelling as it is mathematically rigorous.Related Skills
matplotlib
The foundational library for creating static, animated, and interactive visualizations in Python. Highly customizable and the industry standard for publication-quality figures. Use for 2D plotting, scientific data visualization, heatmaps, contours, vector fields, multi-panel figures, LaTeX-formatted plots, custom visualization tools, and plotting from NumPy arrays or Pandas DataFrames.
xgboost-lightgbm
Industry-standard gradient boosting libraries for tabular data and structured datasets. XGBoost and LightGBM excel at classification and regression tasks on tables, CSVs, and databases. Use when working with tabular machine learning, gradient boosting trees, Kaggle competitions, feature importance analysis, hyperparameter tuning, or when you need state-of-the-art performance on structured data.
xarray
N-dimensional labeled arrays and datasets in Python. Built on top of NumPy and Dask. It introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays, making data analysis in physical sciences more intuitive and less error-prone. Use for working with multi-dimensional scientific data, NetCDF/GRIB/Zarr files, climate/weather/oceanographic datasets, remote sensing, geospatial imaging, large out-of-memory datasets with Dask, and labeled array operations.
transformers
State-of-the-art Machine Learning for PyTorch, TensorFlow, and JAX. Provides thousands of pretrained models to perform tasks on different modalities such as text, vision, and audio. The industry standard for Large Language Models (LLMs) and foundation models in science.
tqdm
A fast, extensible progress bar for Python and CLI. Instantly makes your loops show a smart progress meter with ETA, iterations per second, and customizable statistics. Minimal overhead. Use for monitoring long-running loops, simulations, data processing, ML training, file downloads, I/O operations, command-line tools, pandas operations, parallel tasks, and nested progress bars.
tensorflow
Comprehensive deep learning framework for building, training, and deploying neural networks. TensorFlow provides tf.keras high-level API for model construction, tf.data for efficient data pipelines, and tf.function for graph-mode optimization. Use when working with: neural network training and inference, image classification/detection/segmentation, NLP/text processing with embeddings or transformers, time series forecasting, generative models (VAE, GAN), transfer learning with pretrained models, custom training loops with GradientTape, GPU/TPU accelerated computation, or any deep learning task.
sympy
Comprehensive guide for SymPy - Python library for symbolic mathematics. Use for symbolic expressions, calculus (derivatives, integrals, limits, series), equation solving (algebraic, differential, systems), linear algebra, simplification, matrix operations, special functions, code generation, and mathematical proofs. Essential for analytical mathematics and computer algebra.
sunpy
The community-developed free and open-source software package for solar physics. Provides tools for data search and download, coordinate transformations specific to solar physics, and powerful image processing through the Map object. Use when working with solar data, solar images (EUV, magnetograms, white light), solar coordinates (Helioprojective, Heliographic), Fido data search, solar time series, differential rotation, limb fitting, or multi-instrument solar analysis (AIA, HMI, GOES).
statsmodels
Advanced statistical modeling and hypothesis testing. Complementary to SciPy's stats module, it provides classes and functions for the estimation of many different statistical models, as well as for conducting statistical tests and statistical data exploration. Use for linear regression, GLM, time series analysis, ANOVA, survival analysis, causal inference, and statistical hypothesis testing. Load when working with OLS, WLS, logistic regression, Poisson regression, ARIMA, SARIMAX, statistical diagnostics, p-values, confidence intervals, or R-style statistical analysis.
spacy-nltk
Natural Language Processing for text analysis, corpus linguistics, and production NLP pipelines. spaCy provides fast production-grade tokenization, POS tagging, NER, dependency parsing, and custom model training. NLTK provides classical corpus linguistics, linguistic analysis, VADER sentiment, collocation analysis, and access to standard linguistic corpora. Use when: processing and analyzing text data, extracting named entities (people, orgs, locations, dates), dependency parsing and syntactic analysis, building text classification pipelines, performing corpus-level linguistic analysis (frequency, collocations, readability), sentiment analysis, lemmatization and stemming, working with multilingual text, training custom NER or text classifiers, or any task requiring structured understanding of natural language beyond simple string operations.
sktime-tsfresh
Time series machine learning layer (Tier 1): integration of **sktime** and **tsfresh** for building production-grade pipelines that transform raw time series into tabular feature representations suitable for classical machine-learning models. *sktime* provides a unified, sklearn-compatible interface for time-series data types, transformations, and pipelines, while *tsfresh* enables large-scale automated extraction of statistical, spectral, and autocorrelation features, with optional statistically grounded feature relevance selection (FRESH).
sklearn-explainability
Advanced sub-skill for scikit-learn focused on model interpretability, feature importance, and diagnostic tools. Covers global and local explanations using built-in inspection tools and SHAP/LIME integrations.