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

相关文章

使用python调用zxing库生成二维码图片详解

使用python调用zxing库生成二维码图片详解

(1)安装Jpype 用Python调用jar包需要安装jpype扩展,在Ubuntu上可以直接使用apt-get安装jpype扩展 $ sudo apt-get install...

Python实现数据结构线性链表(单链表)算法示例

Python实现数据结构线性链表(单链表)算法示例

本文实例讲述了Python实现数据结构线性链表(单链表)算法。分享给大家供大家参考,具体如下: 初学python,拿数据结构中的线性链表存储结构练练手,理论比较简单,直接上代码。 #...

在Python dataframe中出生日期转化为年龄的实现方法

在Python dataframe中出生日期转化为年龄的实现方法

我们在做数据挖掘项目或大数据竞赛时,如果个体是人的时候,获得的数据中可能有出生日期的Series,举个简单例子,比如这样的一些数: # -*- coding: utf-8 -*- i...

用Python解析XML的几种常见方法的介绍

用Python解析XML的几种常见方法的介绍

一、简介        XML(eXtensible Markup Language)指可扩展标记语言,被设计用来传输和存储数...

python数字图像处理之高级滤波代码详解

python数字图像处理之高级滤波代码详解

本文提供许多的滤波方法,这些方法放在filters.rank子模块内。 这些方法需要用户自己设定滤波器的形状和大小,因此需要导入morphology模块来设定。 1、autolevel...