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

相关文章

Python2.x和3.x下maketrans与translate函数使用上的不同

maketrans和translate函数是进行字符串字符编码的常用方法。本文着重点在于演示其基本用法和在不同版本下操作的差异。本文提到的2.X版本指2.6以上的版本,3.X版本指3.1...

Python实现重建二叉树的三种方法详解

Python实现重建二叉树的三种方法详解

本文实例讲述了Python实现重建二叉树的三种方法。分享给大家供大家参考,具体如下: 学习算法中,探寻重建二叉树的方法: 用input 前序遍历顺序输入字符重建 前序遍历顺序字...

Python 互换字典的键值对实例

1.zip dic = {'a':1, 'b':2, 'c':3} dic_new = dict(zip(dic.values(), dic.keys())) print(dic_n...

Python实现OpenCV的安装与使用示例

Python实现OpenCV的安装与使用示例

本文实例讲述了Python实现OpenCV的安装与使用。分享给大家供大家参考,具体如下: 由于下一步要开始研究下深度学习,而深度学习领域很多的算法和应用都是用Python来实现的,把Py...

pyqt5 键盘监听按下enter 就登陆的实例

记得导入包,其他按键可类比 def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_Enter:...