复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#方法1:用matplotlib.gridspec.GridSpec自定义网格大小,然后添加子图fig.add_subplot import matplotlib.pyplot as plt import matplotlib.gridspec x1 = np.linspace(0.0, 5.0) x2 = np.linspace(0.0, 2.0) y1 = np.cos(2 * np.pi * x1) * np.exp(-x1) y2 = np.cos(2 * np.pi * x2) gs = matplotlib.gridspec.GridSpec(3,2, width_ratios=[1,1.4], height_ratios=[1,3,1]) fig = plt.figure() ax1 = fig.add_subplot(gs[:,0]) # ax1.plot([1,3,2,4]) ax1.plot(x1, y1, '-og', ms=3) ax2 = fig.add_subplot(gs[1,1]) # ax2.plot([1,3,2,4]) ax2.plot(x2, y2, '-ob', ms=3) plt.show()
复制代码
1
2
3
4#方法二:利用fig.add_axes添加子图,同时指定子图axes的大小(传入比例大小参数) import numpy as np import matplotlib.pyplot as plt fig = plt.fi
最后
以上就是自信薯片最近收集整理的关于Matplotlib可视化过程中如何自定义子图的大小?的全部内容,更多相关Matplotlib可视化过程中如何自定义子图内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复