matplotlib
Helps your agent create and customize scientific plots. It's useful for fine-grained control over plot elements and exporting for publications.
What it does
Matplotlib is a tool for creating charts and data visualizations in Python. It allows you to draw everything from simple line charts to complex scientific visualizations, with full control over their appearance.
When to use it
- ✓Creating line, bar, scatter plots, etc.
- ✓Customizing the appearance of charts (colors, labels, legends).
- ✓Saving charts in formats like PNG or PDF for use in documents.
Example of what to ask your AI
“Create a line chart showing the average temperature trend in São Paulo over the last 5 years.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
You provide the data and the desired chart type. Matplotlib uses this data to draw the chart, allowing you to adjust details like colors, titles, and axes.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add K-Dense-AI/scientific-agent-skills --skill matplotlibOr download just the file:
curl -L https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/main/skills/matplotlib/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Matplotlib
Overview
Matplotlib is Python's foundational visualization library for creating static, animated, and interactive plots. This skill provides guidance on using matplotlib effectively, covering both the pyplot interface (MATLAB-style) and the object-oriented API (Figure/Axes), along with best practices for creating publication-quality visualizations.
When to Use This Skill
This skill should be used when:
- Creating any type of plot or chart (line, scatter, bar, histogram, heatmap, contour, etc.)
- Generating scientific or statistical visualizations
- Customizing plot appearance (colors, styles, labels, legends)
- Creating multi-panel figures with subplots
- Exporting visualizations to various formats (PNG, PDF, SVG, etc.)
- Building interactive plots or animations
- Working with 3D visualizations
- Integrating plots into Jupyter notebooks or GUI applications
Setup
For project work, install Matplotlib with uv:
uv add "matplotlib==3.11.2" numpy scipy
For notebook interactivity:
uv add "matplotlib==3.11.2" ipympl
Then enable the widget backend in Jupyter with %matplotlib widget or %matplotlib ipympl.
Targets Matplotlib 3.11.2 (Python 3.11+), reviewed 2026-10-01. The bundled
scripts and representative examples were executed using Agg and PNG/PDF/SVG output.
GUI windows, Jupyter widgets, and external LaTeX are environment-dependent and were
not exercised. Fragment examples assume imports and named data; adapt and validate
them before use. Check the 3.11 API changes
when migrating older code: use tick_labels and orientation for box plots,
mpl.colormaps[name] for colormaps, and label contour lines rather than contourf.
File output needs no GUI. Use MPLBACKEND=Agg for batch scripts, or select Agg before
importing pyplot. Interactive output requires an installed GUI toolkit such as
PySide6 (QtAgg) or working Tk (TkAgg); plt.ioff() does not remove GUI thread
requirements. See backends.
Core Concepts
The Matplotlib Hierarchy
Matplotlib uses a hierarchical structure of objects:
- Figure - The top-level container for all plot elements
- Axes - The actual plotting area where data is displayed (one Figure can contain multiple Axes)
- Artist - Everything visible on the figure (lines, text, ticks, etc.)
- Axis - The number line objects (x-axis, y-axis) that handle ticks and labels
Two Interfaces
1. pyplot Interface (Implicit, MATLAB-style)
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
- Convenient for quick, simple plots
- Maintains state automatically
- Good for interactive work and simple scripts
2. Object-Oriented Interface (Explicit)
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4])
ax.set_ylabel('some numbers')
plt.show()
- Recommended for most use cases
- More explicit control over figure and axes
- Better for complex figures with multiple subplots
- Easier to maintain and debug
Common Workflows
1. Basic Plot Creation
Single plot workflow:
import matplotlib.pyplot as plt
import numpy as np
# Create figure and axes (OO interface - RECOMMENDED)
fig, ax = plt.subplots(figsize=(10, 6))
# Generate and plot data
x = np.linspace(0, 2*np.pi, 100)
ax.plot(x, np.sin(x), label='sin(x)')
ax.plot(x, np.cos(x), label='cos(x)')
# Customize
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_title('Trigonometric Functions')
ax.legend()
ax.grid(True, alpha=0.3)
# Save and/or display
fig.savefig('plot.png', dpi=300, bbox_inches='tight')
plt.show()
2. Multiple Subplots
Creating subplot layouts:
# Method 1: Regular grid
fig, axes = plt.subplots(2, 2, figsize=(12, 10))
axes[0, 0].plot(x, y1)
axes[0, 1].scatter(x, y2)
axes[1, 0].bar(categories, values)
axes[1, 1].hist(data, bins=30)
# Method 2: Mosaic layout (more flexible)
fig, axes = plt.subplot_mosaic([['left', 'right_top'],
['left', 'right_bottom']],
figsize=(10, 8))
axes['left'].plot(x, y)
axes['right_top'].scatter(x, y)
axes['right_bottom'].hist(data)
# Method 3: GridSpec (maximum control)
from matplotlib.gridspec import GridSpec
fig = plt.figure(figsize=(12, 8))
gs = GridSpec(3, 3, figure=fig)
…
FAQ
What's the difference between pyplot and the object-oriented interface?
Pyplot is simpler for quick plots, while the object-oriented interface offers more control for complex charts and detailed customization.
How do I save my chart?
You can use the `savefig()` function to save the chart to files like PNG, PDF, or SVG.
Can I create multiple charts in the same image?
Yes, Matplotlib allows you to create figures with multiple subplots, organizing several charts side-by-side or in a grid.
Details
Original description by the author
Creates and customizes scientific plots with Matplotlib. Used for fine-grained control over plot elements, novel plot types, and scientific workflows. Export to PNG/PDF/SVG for publication. For quick statistical plots use seaborn; for interactive plots use plotly; for publication-ready multi-panel figures with journal styling, use scientific-visualization.
Popularity
- GitHub stars
- 51k
- Ranking position
- #1905
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
13c-metabolic-flux
Estimates metabolic fluxes using carbon-13 isotope tracing data. It is useful for analyzing cellular metabolism and biochemical pathways.
K-Dense-AI/scientific-agent-skills
adaptyv
Designs protein characterization experiments using the Adaptyv API. It helps estimate costs, submit sequences, and monitor lab results.
K-Dense-AI/scientific-agent-skills
aeon
Performs machine learning tasks on time series data. It is useful for classifying, forecasting, detecting anomalies, and finding patterns in sequential data.
K-Dense-AI/scientific-agent-skills
alphagenome
Looks up precomputed genomic effects for genetic variants. It provides scores and explanations to understand the impact of variants on the genome.
K-Dense-AI/scientific-agent-skills
Similar skills
ios-icon-gen
Lets your agent generate icons for iOS apps. It uses Apple symbols or icons from other sources to create the correct files.
affaan-m/ECC
algorithmic-art
Helps your agent create art using code, generating unique images. It's useful when you want original computer-generated art.
anthropics/skills
canvas-design
Helps your agent create beautiful visual art in files. It's useful when you ask for a poster, art, or any static design.
anthropics/skills