Python/Matplotlib-更改子图的相对大小 [英] Python/Matplotlib - Change the relative size of a subplot

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

问题描述

我有两个情节

import matplotlib.pyplot as plt
plt.subplot(121)
plt.subplot(122)

我希望plt.subplot(122)的宽度是plt.subplot(121)的一半.是否有一种直接的方法来设置子图的高度和宽度参数?

I want plt.subplot(122) to be half as wide as plt.subplot(121). Is there a straightforward way to set the height and width parameters for a subplot?

推荐答案

通过简单地用"122"指定几何形状,就隐含地获得了自动且大小相等的列和行布局.

By simply specifying the geometry with "122", you're implicitly getting the automatic, equal-sized columns-and-rows layout.

要自定义布局网格,您需要更加具体.请参阅Matplotlib文档中的"使用GridSpec定制子图的位置".

To customise the layout grid, you need to get a little more specific. See "Customizing Location of Subplot Using GridSpec" in the Matplotlib docs.

这篇关于Python/Matplotlib-更改子图的相对大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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