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程序设计入门(5)类的使用简介

一、类的定义和使用 python定义一个类的基本语法是: 复制代码 代码如下:class classname([基类一,基类二...]):     [def...

解决tensorflow1.x版本加载saver.restore目录报错的问题

这个错误是最新的错误哈,目前只在tensorflow上的github仓库上面有提出,所以你在百度上面找不到。 是个tensorflow的bug十天前提出的,只有github仓库上一个地方...

Python实现的逻辑回归算法示例【附测试csv文件下载】

Python实现的逻辑回归算法示例【附测试csv文件下载】

本文实例讲述了Python实现的逻辑回归算法。分享给大家供大家参考,具体如下: 使用python实现逻辑回归 Using Python to Implement Logistic Reg...

python数据类型_元组、字典常用操作方法(介绍)

元组 Python的元组与列表类似,不同之处在于元组的元素不能修改。 元组使用小括号,列表使用方括号。 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可。 tp=(1,2,...

Python字符串的修改方法实例

这篇文章主要介绍了Python字符串的修改方法实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 我们在修改字符串时 通常遇到报错:...