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

相关文章

pyqt5与matplotlib的完美结合实例

具体用到了matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg 直接上代码(这里给出的只是一个简单的框架,告诉你怎么去写): #...

给Python初学者的一些编程技巧

交换变量   x = 6 y = 5 x, y = y, x print x >>> 5 print y >>> 6 if...

python求列表交集的方法汇总

本文实例汇总了python求列表交集的方法。分享给大家供大家参考。具体方法如下: 交集对于给定的两个集合A 和 集合B 的交集是指含有所有既属于 A 又属于 B 的元素,而没有其他元素的...

使用python来调用CAN通讯的DLL实现方法

由于工作上的需要,经常要与USBCAN打交道,但厂家一般不会提供PYTHON的例子,于是自己摸索地写一个例子出来,以便在工作上随时可以使用PYTHON来测试CAN的功能。这里的例子是使用...

python入门前的第一课 python怎样入门

python入门前的第一课 python怎样入门

人工智能时代的到来,很多文章说这么一句:“不会python,就不要说自己是程序员”,这说的有点夸张了,但确实觉得目前python这个语言值得学习,而且会python是高薪程序员的必备技能...