示例
关于我们提供的绘图方法的概述,请参见 图表类型
本页包含示例图表。点击任意图片查看完整图片和源代码。
对于更长的教程,请参阅我们的 教程页面。您还可以在我们的 用户指南 中找到 外部资源 和 常见问题解答。
线条、条形和标记
水平条形图
Horizontal bar chart
绘制分类变量
Plotting categorical variables
离散分布作为水平条形图
Discrete distribution as horizontal bar chart
虚线样式配置
Dashed line style configuration
标记参考
Marker reference
多色线条
Multicolored lines
标记示例
Marker examples
线图
Line plot
频谱表示
Spectrum representations
堆叠图和流图
Stackplots and streamgraphs
图像、轮廓和场
图像的仿射变换
Affine transform of an image
风羽
Wind barbs
交互式调整色图范围
Interactive adjustment of colormap range
轮廓角掩码
Contour corner mask
优化解决方案空间的轮廓
Contouring the solution space of optimizations
修改坐标格式化器
Modifying the coordinate formatter
高级箭袋和箭袋键功能
Advanced quiver and quiverkey functions
阴影示例
Shading example
频谱图
Spectrogram
水印图片
Watermark image
统计
分离箱线图的计算和绘制
Separate calculation and plotting of boxplots
绘制二维数据集的置信椭圆
Plot a confidence ellipse of a two-dimensional dataset
指定误差线的不同方式
Different ways of specifying error bars
在误差条中包含上下限
Including upper and lower limits in error bars
累积分布
Cumulative distributions
并排的多个直方图
Multiple histograms side by side
饼图和极坐标图
饼图
Pie charts
嵌套饼图
Nested pie charts
极坐标散点图
Scatter plot on polar axis
文本、标签和注释
注释变换
Annotate transform
注释图表
Annotating a plot
自定义图例
Compose custom legends
注释箭头样式参考
Annotation arrow style reference
图例演示
Figure legend demo
配置字体族
Configure the font family
子图标签
Labelling subplots
数学表达式
Mathematical expressions
数学字体
Math fontfamily
多行
Multiline
文本属性
Text properties
使用字典控制文本和标签的样式
Controlling style of text and labels using a dictionary
标题定位
Title positioning
颜色
有关 Matplotlib 中可用的色图描述,请参阅 色图教程。
色图参考
Colormap reference
从色图中选择单个颜色
Selecting individual colors from a colormap
形状和集合
海豚
Dolphins
椭圆集合
Ellipse Collection
散点图
Scatter plot
样式表
暗背景样式表
Dark background style sheet
灰度样式表
Grayscale style sheet
样式表引用
Style sheets reference
模块 - pyplot
无限行
Infinite lines
模块 - axes_grid1
锚定方向箭头
Anchored Direction Arrow
模块 - axisartist
轴方向
Axis Direction
轴方向演示
axis_direction demo
轴线样式
Axis line styles
简单轴垫
Simple axis pad
简单轴线
Simple Axisline
展示
图的结构
Anatomy of a figure
动画
双摆问题
The double pendulum problem
帧抓取
Frame grabbing
多轴动画
Multiple Axes animation
暂停和恢复动画
Pause and resume an animation
雨模拟
Rain simulation
示波器
Oscilloscope
事件处理
Matplotlib 支持 事件处理 ,采用与 GUI 无关的事件模型,因此您可以在不了解 Matplotlib 最终连接到哪个用户界面的情况下连接到 Matplotlib 事件。这有两个优点:您编写的代码将更具可移植性,并且 Matplotlib 事件能够感知数据坐标空间和事件发生的轴,因此您无需处理低级变换细节即可从画布空间转换到数据空间。还包括对象拾取的示例。
交互功能
Interactive functions
镜子
Looking glass
杂项
字体属性
Font properties
多进程
Multiprocessing
打包气泡图
Packed-bubble chart
矢量图形的栅格化
Rasterization for vector graphics
3D 绘图
相交的平面
Intersecting planes
参数曲线
Parametric curve
自动文本偏移
Automatic text offsetting
刻度
这些示例涵盖了在 Matplotlib 中如何处理不同尺度。
探索归一化
Exploring normalizations
专业图表
石川图
Ishikawa Diagram
左心室靶心图
Left ventricle bullseye
地形山体阴影
Topographic hillshading
书脊
脊柱放置
Spine placement
Ticks
自动设置刻度位置
Automatically setting tick positions
从值列表设置刻度标签
Setting tick labels from a list of values
单位
这些示例涵盖了 Matplotlib 中单位的多种表示方式。
英寸和厘米
Inches and centimeters
在图形用户界面中嵌入 Matplotlib
你可以通过遵循这里的 embedding_in_SOMEGUI.py 示例,将 Matplotlib 直接嵌入到用户界面应用程序中。目前,Matplotlib 支持 PyQt/PySide、PyGObject、Tkinter 和 wxPython。
在GUI中嵌入Matplotlib时,必须直接使用Matplotlib API,而不是pylab/pyplot过程接口,因此请查看examples/api目录中的一些示例代码,了解如何使用API。