在python matplotlib中更改子图大小 [英] Change subplot size in python matplotlib

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

问题描述

当我使用Python的matplotlib时,我想更改 subplot 的大小.我已经知道如何更改的大小,但是,如何更改相应子图本身的大小呢?在我的谷歌搜索中,这仍然有些难以捉摸.谢谢.

I would like to change the size of the subplot when I use Python's matplotlib. I already know how to change the size of the figure, however, how does one go about changing the size of the corresponding subplots themselves? This has remained somewhat elusive in my googling. Thanks.

(例如,给定一个图形,其中有2x4个子图.我想使该图内的子图占据更多的区域).

(For example, given a figure where we have 2x4 subplots. I want to make the subplots within the figure occupy more area).

推荐答案

您还可以使用轴的尺寸进行播放. http://matplotlib.org/api/axes_api.html

You can also play with the axis size. http://matplotlib.org/api/axes_api.html

set_position()可用于更改轴的宽度和高度.

set_position() can be used to change width and height of your axis.

import matplotlib.pyplot as plt

ax = plt.subplot(111)

box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 1.1 , box.height * 1.1])

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

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