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设计】。

相关文章

解决Pytorch训练过程中loss不下降的问题

在使用Pytorch进行神经网络训练时,有时会遇到训练学习率不下降的问题。出现这种问题的可能原因有很多,包括学习率过小,数据没有进行Normalization等。不过除了这些常规的原因,...

python 环境搭建 及python-3.4.4的下载和安装过程

python 环境搭建 及python-3.4.4的下载和安装过程

第一步:下载和安装python-3.4.4amd.msi 可以去官方网站下载,也可以从网盘下载: 链接: https://pan.baidu.com/s/1hLn2y51lHiTGXCj...

使用python读取.text文件特定行的数据方法

使用python读取.text文件特定行的数据方法

如何用python循环读取下面.txt文件中,用红括号标出来的数据呢? 首先,观察数据可知,不同行的第一个数据元素不一样,所以考虑直接用正则表达式。 再加上,对读和写文件的操作,就行了...

Python3.5面向对象与继承图文实例详解

Python3.5面向对象与继承图文实例详解

本文实例讲述了Python3.5面向对象与继承。分享给大家供大家参考,具体如下: 1、编程的方式 2、面向对象的基本概念 3、类的基本概念 4、类的定义与调...

解决Pycharm运行时找不到文件的问题

解决Pycharm运行时找不到文件的问题

这是解释器设置问题,在设置里找到interpreter 找到合适的目录就可以了。因为重装了python导致pycharm找不到路径了。 另外,pycharm找不到tensorflow包的...