自定义 Matplotlib 子图 [英] Customising Matplotlib Subplots

查看:55
本文介绍了自定义 Matplotlib 子图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是发现matplotlib子图令人困惑,所以我想知道是否有人可以展示如何生成以下子图排列:

I've always found matplotlib subplots confusing, and so I was wondering whether somebody could show how to generate the following arrangement of subplots: Subplot Image

Thanks in advance.

解决方案

You can use plt.GridSpec to easily create differently sized subplots.

cols = 5   #number of columns in the grid
s    = 2   #width of top right subplot in #cells
w    = 1   #spacing between subplot columns

fig = plt.figure()
gs  = plt.GridSpec(2, cols, figure=fig, wspace=w)
ax1 = fig.add_subplot(gs[0, :-s])
ax2 = fig.add_subplot(gs[0, -s:])
ax3 = fig.add_subplot(gs[1, :-s])

这篇关于自定义 Matplotlib 子图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆