matplotlib
Low-level plotting library for full customization. Use when you need fine-grained control over every plot element, creating novel plot types, or integrating with specific 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.
Author
Category
Development ToolsInstall
Hot:24
Download and extract to your skills directory
Copy command and send to AI Agent for auto-install:
Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-skills-matplotlib&locale=en&source=copy
Matplotlib - A Complete Guide to Python Data Visualization Plotting Library
Skills Overview
Matplotlib is a fundamental Python visualization library for creating static, animated, and interactive charts. It offers a complete plotting solution, ranging from simple line charts to complex, publication-quality scientific figures.
Use Cases
Core Features
Frequently Asked Questions
How to set Chinese display in matplotlib?
Chinese display issues usually require font configuration. You can solve it in the following ways:
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei', 'Arial Unicode MS', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False # Fix negative sign display issuesIf your system lacks Chinese fonts, install the corresponding font package or use another font that includes Chinese characters.
What is the difference between matplotlib and seaborn, and which should I use?
Matplotlib is a low-level plotting library that offers fine control but requires more code. Seaborn is built on top of matplotlib, providing a high-level statistical chart interface with simpler code but weaker customization. Recommendations:
How to save high-resolution images for paper submissions?
Use the
savefig() method and set appropriate parameters:fig.savefig('figure.png', dpi=300, bbox_inches='tight', facecolor='white')Key parameters:
dpi=300: publication-level resolution (150 for web, 72 for screen)bbox_inches='tight': automatically crop extra whitespacefacecolor='white': ensure a white backgroundHow to use matplotlib in a Jupyter notebook?
First install an interactive backend:
uv add matplotlib ipymplThen run in the notebook:
%matplotlib widget # or %matplotlib ipymplThis allows charts to be interactively zoomed and manipulated within the notebook. If interaction is not needed, use
%matplotlib inline.Is matplotlib suitable for interactive visualization?
Matplotlib is mainly designed for static charts and animations. Although it supports basic interactivity (such as zooming and panning), for complex interactive visualizations (like hover tooltips and dynamic updates), it’s recommended to use specialized interactive visualization libraries such as plotly or bokeh. Matplotlib is better suited for generating final static outputs.
How to create multi-subplot layouts?
Matplotlib provides three layout methods:
plt.subplots(2, 2) to create a 2×2 gridplt.subplot_mosaic() to flexibly arrange subplotsFor the object-oriented interface, it’s recommended to use constrained_layout=True to automatically handle spacing between subplots and prevent element overlap.