matplotlib

Create static, animated, and interactive plots with matplotlib's pyplot and object-oriented APIs.

Updated Feb 27, 2026
One-click install
npx skills add https://github.com/gracefullight/cnn --skill matplotlib-gracefullight
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: matplotlib
Source: https://github.com/gracefullight/cnn/tree/main/.agents/skills/matplotlib
Command: npx skills add https://github.com/gracefullight/cnn --skill matplotlib-gracefullight

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires matplotlib, numpy, scipy, and includes scripts (resource) and references (resource) components.

What problem does it solve? Creating publication-quality data visualizations in Python requires navigating matplotlib's dual interfaces, extensive customization options, and common pitfalls like overlapping layouts, memory leaks, and colormap misuse. This Skill provides structured guidance, templates, and troubleshooting references to produce correct, well-styled figures without trial and error. ## Core Features & Use Cases - Comprehensive Plot Guidance: Covers line, scatter, bar, histogram, heatmap, contour, box, violin, 3D, polar, and animation plots using the recommended object-oriented Figure/Axes API. - Styling and Export: Explains colormap selection, rcParams configuration, style sheets, and exporting to PNG, PDF, or SVG at publication-ready resolutions. - Helper Scripts and References: Includes a plot template generator, an interactive style configurator producing .mplstyle files, and detailed references for plot types, styling, the API, and common issues. - Use Case: A researcher needs a multi-panel figure with a shared colorbar for a journal submission. Use this Skill to build the GridSpec layout, apply a colorblind-friendly colormap, and export a 300 DPI PDF. ## Quick Start Ask the AI to create a multi-panel matplotlib figure with subplots showing a line plot, scatter plot, and heatmap, then export it as a 300 DPI PNG.

Frequently Asked Questions about matplotlib

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create subplots in matplotlib?▼

Use plt.subplots(nrows, ncols) to create a figure with a grid of axes, then index into the returned axes array to plot on each one. For irregular layouts, use plt.subplot_mosaic or GridSpec to span rows and columns.

What is the difference between pyplot and the object-oriented API in matplotlib?▼

The pyplot interface maintains implicit global state and suits quick interactive plots, while the object-oriented API explicitly manages Figure and Axes objects. The object-oriented approach is recommended for production code and complex multi-panel figures.

How do I save a matplotlib figure as a high-resolution PNG or PDF?▼

Call plt.savefig with the desired filename and set dpi=300 for publication-quality PNG output. Use bbox_inches='tight' to remove excess whitespace, and save as .pdf or .svg for scalable vector formats.

Why do my matplotlib labels and titles overlap or get cut off?▼

Overlapping happens because default spacing does not account for label sizes. Fix it by creating the figure with constrained_layout=True, calling plt.tight_layout(), or saving with bbox_inches='tight'.

Which colormap should I use for matplotlib plots?▼

Use perceptually uniform sequential colormaps like viridis or plasma for ordered data, diverging colormaps like coolwarm for data centered on a meaningful value, and qualitative colormaps like tab10 for categories. Avoid jet, which is not perceptually uniform.

When should I use seaborn or plotly instead of matplotlib?▼

Use seaborn for quick statistical plots with sensible defaults and plotly for interactive web-based visualizations. Matplotlib is the right choice when you need fine-grained control over every plot element or publication-quality static output.