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实现的Kmeans++算法实例

1、从Kmeans说起 Kmeans是一个非常基础的聚类算法,使用了迭代的思想,关于其原理这里不说了。下面说一下如何在matlab中使用kmeans算法。 创建7个二维的数据点:复制代码...

python 图像处理画一个正弦函数代码实例

python 图像处理画一个正弦函数代码实例

这篇文章主要介绍了python 图像处理画一个正弦函数代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 import num...

Python实现朴素贝叶斯的学习与分类过程解析

Python实现朴素贝叶斯的学习与分类过程解析

 概念简介: 朴素贝叶斯基于贝叶斯定理,它假设输入随机变量的特征值是条件独立的,故称之为“朴素”。简单介绍贝叶斯定理: 乍看起来似乎是要求一个概率,还要先得到额外三个概率,...

python matplotlib画图实例代码分享

python matplotlib画图实例代码分享

python的matplotlib包支持我们画图,有点非常多,现学习如下。 首先要导入包,在以后的示例中默认已经导入这两个包 import matplotlib.pyplot as...

Python面向对象编程之继承与多态详解

Python面向对象编程之继承与多态详解

本文实例讲述了Python面向对象编程之继承与多态。分享给大家供大家参考,具体如下: Python 类的继承 在OOP(Object Oriented Programming)程序设计中...