matplotlib subplots 调整子图间矩的实例

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

相关文章

centos6.5安装python3.7.1之后无法使用pip的解决方案

编译安装全是坑…… 第一遍装完无法使用pip,报错找不到ssl模块。各种报错: pip is configured with locations that require TLS/SS...

python获取Linux下文件版本信息、公司名和产品名的方法

本文实例讲述了python获取Linux下文件版本信息、公司名和产品名的方法,分享给大家供大家参考。具体如下: 区别于前文所述。本例是在linux下得到文件版本信息,主要是通过pefil...

使用python 获取进程pid号的方法

保存为.py文件后 运行脚本在后面添加进程名称即可 比如:python proinfo.py qq 即可获取QQ的进程信息,注意不区分大小写 复制代码 代码如下:#-*- encodin...

python中字符串类型json操作的注意事项

python操作json的方法有 json.dumps——将json对象(字典)转换为字符串对象 json.loads——将字符串对象转换为json对象(字典) 如果定义json对...

Python中使用__new__实现单例模式并解析

单例模式是一个经典设计模式,简要的说,一个类的单例模式就是它只能被实例化一次,实例变量在第一次实例化时就已经固定。  在Python中常见的单例模式有None,这就是一个很典...