python - matplotlib add_subplot 奇数个地 block

标签 python matplotlib

我知道 add_subplot() 生成了一个方格图,我正在用 4x4 网格来做,但我还需要一个。我怎样才能做同样的事情但使用奇数个地 block 并使其看起来像这样? odd grid

最佳答案

您需要使用 gridspec 子模块:

fig = pyplot.figure(figsize=(6, 4))
gs = gridspec.GridSpec(nrows=6, ncols=2)

ax11 = fig.add_subplot(gs[:2, 0])
ax21 = fig.add_subplot(gs[2:4, 0])
ax31 = fig.add_subplot(gs[4:, 0])
ax12 = fig.add_subplot(gs[:3, 1])
ax22 = fig.add_subplot(gs[3:, 1])
fig.tight_layout()

enter image description here

关于python - matplotlib add_subplot 奇数个地 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41025187/

相关文章:

matplotlib - 如何使用 gcf() 或 gca() 自定义 matplotlib 图?

python - Ruby 相当于 Python 的 subprocess.check_call/check_output

Python读取带有相关子元素的xml

python - 使用 matplotlib 在 Python 中绘制参数图

matplotlib - 无法安装 matplotlib

python - matplotlib draw() 卡住窗口

python - 如何存储/保存和恢复tensorflow DNNClassifier(没有要保存的变量)

python - openssl,python请求错误: "certificate verify failed"

python - python中的str.isdigit,isnumeric和isdecimal有什么区别?

matplotlib - iPython 笔记本 : How to prevent from outputting image on imshow()?