npx skills add ...
npx skills add davila7/claude-code-templates --skill matplotlib
Foundational plotting library. Create line plots, scatter, bar, histograms, heatmaps, 3D, subplots, export PNG/PDF/SVG, for scientific visualization and publication figures.
npx skills add davila7/claude-code-templates --skill matplotlib
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.
This skill should be used when:
Matplotlib uses a hierarchical structure of objects:
1. pyplot Interface (Implicit, MATLAB-style)
2. Object-Oriented Interface (Explicit)
Single plot workflow:
Creating subplot layouts:
Line plots - Time series, continuous data, trends
Scatter plots - Relationships between variables, correlations
Bar charts - Categorical comparisons
Histograms - Distributions
Heatmaps - Matrix data, correlations
Contour plots - 3D data on 2D plane
Box plots - Statistical distributions
Violin plots - Distribution densities
For comprehensive plot type examples and variations, refer to references/plot_types.md.
Color specification methods:
'red', 'blue', 'steelblue''#FF5733'(0.1, 0.2, 0.3)cmap='viridis', cmap='plasma', cmap='coolwarm'Using style sheets:
Customizing with rcParams:
Text and annotations:
For detailed styling options and colormap guidelines, see references/styling_guide.md.
Export to various formats:
Important parameters:
dpi: Resolution (300 for publications, 150 for web, 72 for screen)bbox_inches='tight': Removes excess whitespacefacecolor='white': Ensures white background (useful for transparent themes)transparent=True: Transparent backgroundfig, ax = plt.subplots(figsize=(10, 6))constrained_layout=True or tight_layout() to prevent overlapping elementsfig, ax = plt.subplots(constrained_layout=True) is recommended for automatic spacingrasterized=True in plot calls to reduce file sizeThis skill includes helper scripts in the scripts/ directory:
plot_template.pyTemplate script demonstrating various plot types with best practices. Use this as a starting point for creating new visualizations.
Usage:
style_configurator.pyInteractive utility to configure matplotlib style preferences and generate custom style sheets.
Usage:
For comprehensive information, consult the reference documents:
references/plot_types.md - Complete catalog of plot types with code examples and use casesreferences/styling_guide.md - Detailed styling options, colormaps, and customizationreferences/api_reference.md - Core classes and methods referencereferences/common_issues.md - Troubleshooting guide for common problemsMatplotlib integrates well with:
%matplotlib inline or %matplotlib widgetconstrained_layout=True or tight_layout()plt.close(fig)plt.rcParams['font.sans-serif']pixels = dpi * inches