
Matplotlib
Look up Figure, Axes, and common plotting APIs while agents generate charts, dashboards, or notebook visuals.
Overview
matplotlib is an agent skill most often used in Build (also Validate, Grow) that supplies Figure/Axes API reference for correct Python chart code.
Install
npx skills add https://github.com/davila7/claude-code-templates --skill matplotlibWhat is this skill?
- Figure and Axes lifecycle: subplots, tight_layout, savefig, close
- Line, scatter, bar, histogram, and image plotting method quick reference
- Styling hooks: labels, legends, grids, spines, colorbars
- Layout patterns: subplots, GridSpec, twin axes, inset axes
- Publication-oriented savefig and dpi guidance
Adoption & trust: 786 installs on skills.sh; 27.8k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your coding agent invents matplotlib calls or mixes pyplot and object-oriented APIs, producing broken or non-reproducible plots.
Who is it for?
Solo builders generating Python visualizations in notebooks, CLI tools, or backend report endpoints with agent assistance.
Skip if: Teams needing interactive BI (Plotly/Dash), automated chart QA, or full pandas/seaborn pipeline design without additional skills.
When should I use this skill?
Agent is writing or refactoring Python matplotlib charts and needs accurate Figure, Axes, and styling method names.
What do I get? / Deliverables
Generated plotting code follows idiomatic Figure and Axes patterns with consistent labels, layout, and savefig settings.
- Idiomatic matplotlib plotting snippets
- Layout and export-ready figure configuration
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Build is the primary shelf because the skill is procedural reference material used while implementing visualization code, not while ideating markets or operating alerts. Docs subphase fits API-reference shape: class/method cheat sheets agents consult mid-implementation rather than shipping tests or infra.
Where it fits
Generate server-side PNG reports using Axes.plot and tight_layout before attaching charts to a Flask or FastAPI endpoint.
Quickly chart funnel or cohort metrics for a landing-page experiment without adopting a full BI stack.
Standardize weekly retention or revenue charts in internal dashboards with consistent savefig dpi.
How it compares
API cheat sheet for matplotlib OOP plotting—not a data-ingestion skill or a substitute for Jupyter execution environments.
Common Questions / FAQ
Who is matplotlib for?
Developers and indie data hackers who want agents to write correct, readable matplotlib while building analytics features or reports.
When should I use matplotlib?
In Build while implementing charts in apps or scripts, in Validate when sketching prototype metrics visuals, and in Grow when refining analytics or lifecycle report graphics.
Is matplotlib safe to install?
It is reference documentation only with no declared runtime hooks; still review the Security Audits panel on this page before adding any skill from the catalog.
SKILL.md
READMESKILL.md - Matplotlib
# Matplotlib API Reference This document provides a quick reference for the most commonly used matplotlib classes and methods. ## Core Classes ### Figure The top-level container for all plot elements. **Creation:** ```python fig = plt.figure(figsize=(10, 6), dpi=100, facecolor='white') fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 6)) fig, axes = plt.subplots(2, 2, figsize=(12, 10)) ``` **Key Methods:** - `fig.add_subplot(nrows, ncols, index)` - Add a subplot - `fig.add_axes([left, bottom, width, height])` - Add axes at specific position - `fig.savefig(filename, dpi=300, bbox_inches='tight')` - Save figure - `fig.tight_layout()` - Adjust spacing to prevent overlaps - `fig.suptitle(title)` - Set figure title - `fig.legend()` - Create figure-level legend - `fig.colorbar(mappable)` - Add colorbar to figure - `plt.close(fig)` - Close figure to free memory **Key Attributes:** - `fig.axes` - List of all axes in the figure - `fig.dpi` - Resolution in dots per inch - `fig.figsize` - Figure dimensions in inches (width, height) ### Axes The actual plotting area where data is visualized. **Creation:** ```python fig, ax = plt.subplots() # Single axes ax = fig.add_subplot(111) # Alternative method ``` **Plotting Methods:** **Line plots:** - `ax.plot(x, y, **kwargs)` - Line plot - `ax.step(x, y, where='pre'/'mid'/'post')` - Step plot - `ax.errorbar(x, y, yerr, xerr)` - Error bars **Scatter plots:** - `ax.scatter(x, y, s=size, c=color, marker='o', alpha=0.5)` - Scatter plot **Bar charts:** - `ax.bar(x, height, width=0.8, align='center')` - Vertical bar chart - `ax.barh(y, width)` - Horizontal bar chart **Statistical plots:** - `ax.hist(data, bins=10, density=False)` - Histogram - `ax.boxplot(data, labels=None)` - Box plot - `ax.violinplot(data)` - Violin plot **2D plots:** - `ax.imshow(array, cmap='viridis', aspect='auto')` - Display image/matrix - `ax.contour(X, Y, Z, levels=10)` - Contour lines - `ax.contourf(X, Y, Z, levels=10)` - Filled contours - `ax.pcolormesh(X, Y, Z)` - Pseudocolor plot **Filling:** - `ax.fill_between(x, y1, y2, alpha=0.3)` - Fill between curves - `ax.fill_betweenx(y, x1, x2)` - Fill between vertical curves **Text and annotations:** - `ax.text(x, y, text, fontsize=12)` - Add text - `ax.annotate(text, xy=(x, y), xytext=(x2, y2), arrowprops={})` - Annotate with arrow **Customization Methods:** **Labels and titles:** - `ax.set_xlabel(label, fontsize=12)` - Set x-axis label - `ax.set_ylabel(label, fontsize=12)` - Set y-axis label - `ax.set_title(title, fontsize=14)` - Set axes title **Limits and scales:** - `ax.set_xlim(left, right)` - Set x-axis limits - `ax.set_ylim(bottom, top)` - Set y-axis limits - `ax.set_xscale('linear'/'log'/'symlog')` - Set x-axis scale - `ax.set_yscale('linear'/'log'/'symlog')` - Set y-axis scale **Ticks:** - `ax.set_xticks(positions)` - Set x-tick positions - `ax.set_xticklabels(labels)` - Set x-tick labels - `ax.tick_params(axis='both', labelsize=10)` - Customize tick appearance **Grid and spines:** - `ax.grid(True, alpha=0.3, linestyle='--')` - Add grid - `ax.spines['top'].set_visible(False)` - Hide top spine - `ax.spines['right'].set_visible(False)` - Hide right spine **Legend:** - `ax.legend(loc='best', fontsize=10, frameon=True)` - Add legend - `ax.legend(handles, labels)` - Custom legend **Aspect and layout:** - `ax.set_aspect('equal'/'auto'/ratio)` - Set aspect ratio - `ax.invert_xaxis()` - Invert x-axis - `ax.invert_yaxis()` - Invert y-axis ### pyplot Module High-level interface for quick plotting. **Figure creation:** - `plt.figure()` - Create new figure - `plt.subplots()` - Create figure and axes - `plt.subplot()` - Add subplot to current figure **Plotting (uses current axes):** - `plt.plot()` - Line plot - `plt.scatter()` - Scatter plot - `plt.bar()` - Bar chart - `plt.hist()` - Histogram - (All axes methods available) **Display and save:** - `plt.show()` - Display figure - `plt.savefig()` - Save figure - `plt.close()` - Close figure **Style: