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中实现指定时间调用函数示例代码

前言 本文主要给大家介绍了关于python指定时间调用函数的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍: 在前面的一篇文章里,可以使用延时调用,在这里采用指定...

Python线程创建和终止实例代码

python主要是通过thread和threading这两个模块来实现多线程支持。 python的thread模块是比較底层的模块,python的threading模块是对thread做...

对python读写文件去重、RE、set的使用详解

如下所示: # -*- coding:utf-8 -*- from datetime import datetime import re def Main(): sou...

scikit-learn线性回归,多元回归,多项式回归的实现

scikit-learn线性回归,多元回归,多项式回归的实现

匹萨的直径与价格的数据 %matplotlib inline import matplotlib.pyplot as plt def runplt(): plt.figure()...

用Python实现大文本文件切割的方法

在实际工作中,有些场景下,因为产品既有功能限制,不支持特大文件的直接处理,需要把大文件进行切割处理。 当然可以通过UltraEdit编辑工具,或者从网上下载一些文件切割器之类的。但这些要...