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

相关文章

Python3内置模块pprint让打印比print更美观详解

概述 在我们使用内置打印函数print时,打印出的Python数据结构对象总是一行的输出的方式,这样对数据结构较复杂或数据较多的对象的显示并不美观,这时我们可以利用pprint输出美化...

Python中使用PyHook监听鼠标和键盘事件实例

PyHook是一个基于Python的“钩子”库,主要用于监听当前电脑上鼠标和键盘的事件。这个库依赖于另一个Python库PyWin32,如同名字所显示的,PyWin32只能运行在Wind...

对python numpy数组中冒号的使用方法详解

对python numpy数组中冒号的使用方法详解

python中冒号实际上有两个意思:1.默认全部选择;2. 指定范围。 下面看例子 定义数组 X=array([[1,2,3,4],[5,6,7,8],[9,10,11,12],[1...

Python 中list ,set,dict的大规模查找效率对比详解

很多时候我们可能要频繁的进行元素的find 或in操作,本人一直天真的以为python的list做了hash,通过红黑树来高效查找···直到今天我真正来测试它和set,dict的查找效率...

Django的Modelforms用法简介

Django的Modelforms用法简介

from django.forms import ModelForm class Test(ModelForm): # 把那张表转化成form组件 class Me...