matplotlib subplots 调整子图间矩的实例

yipeiwu_com5年前Python基础

在matplotlib中,用subplots画子图时,有时候需要调整子图间矩,包括子图与边框的间矩,子图间上下间矩,子图间左右间矩,可以使用fig.tight_layout()函数:

Help on method tight_layout in module matplotlib.figure:

tight_layout(renderer=None, pad=1.08, h_pad=None, w_pad=None, rect=None) method of matplotlib.figure.Figure instance
  Adjust subplot parameters to give specified padding.
  
  Parameters:
  
   *pad* : float
    padding between the figure edge and the edges of subplots,
    as a fraction of the font-size.
   *h_pad*, *w_pad* : float
    padding (height/width) between edges of adjacent subplots.
    Defaults to `pad_inches`.
   *rect* : if rect is given, it is interpreted as a rectangle
    (left, bottom, right, top) in the normalized figure
    coordinate that the whole subplots area (including
    labels) will fit into. Default is (0, 0, 1, 1).

以上这篇matplotlib subplots 调整子图间矩的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python lxml模块安装教程

lxml是Python中与XML及HTML相关功能中最丰富和最容易使用的库。lxml并不是Python自带的包,而是为libxml2和libxslt库的一个Python化的绑定。它与众不...

Python Process多进程实现过程

Python Process多进程实现过程

进程的概念 程序是没有运行的代码,静态的; 进程是运行起来的程序,进程是一个程序运行起来之后和资源的总称; 程序只有一个,但同一份程序可以有多个进程;例如,电脑上多开QQ; 程序和进程...

python使用pip安装模块出现ReadTimeoutError: HTTPSConnectionPool的解决方法

今天使用pip安装第三库时,有时会报错: pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(hos...

python在html中插入简单的代码并加上时间戳的方法

python在html中插入简单的代码并加上时间戳的方法

建议用pycharm,使用比较方便,并且可以直接编辑html文件 import time locatime = time.strftime("%Y-%m-%d" ) report =...

python创建学生成绩管理系统

python创建学生成绩管理系统

python学生成绩管理系统创建,供大家参考,具体内容如下 要求编写学生类,班级类,并在电脑运行生成表单,输入一个数字,得到对应的结果。 输出样式 代码如下 学生类 class S...