  
- UID
- 2
- 积分
- 2909960
- 威望
- 1405012 布
- 龙e币
- 1504948 刀
- 在线时间
- 13497 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-2-18

|
Matplotlib(绘图库)- 创建绘图区域
在绘图结构中,figure 创建窗口,subplot 创建子图。所有的绘画只能在子图上进行。plt 表示当前子图,若没有就创建一个子图。所有你会看到一些教程中使用 plt 进行设置,一些教程使用子图属性进行设置。他们往往存在对应功能函数。
Figure:面板(图),matplotlib中的所有图像都是位于figure对象中,一个图像只能有一个figure对象。 Subplot:子图,figure对象下创建一个或多个subplot对象(即axes)用于绘制图像。使用 subplot 函数的时候,你需要指明网格的行列数量,以及你希望将图样放在哪一个网格区域中。例如:
2行1列

1行2列

2行2列
 - # ---绘制多个图表---
- # 创建figure对象
- fig = plt.figure()
- # 创建subplot---(221:前两个2表示2*2,两行两列,最后一个1表示创建第几个)
- ax1 = fig.add_subplot(2,2,1)
- ax2 = fig.add_subplot(2,2,2)
- ax3 = fig.add_subplot(2,2,3)
- ax4 = fig.add_subplot(2,2,4)
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|