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操作数据库之sqlite3打开数据库、删除、修改示例

复制代码 代码如下:#coding=utf-8__auther__ = 'xianbao'import sqlite3# 打开数据库def opendata():  ...

Python 将RGB图像转换为Pytho灰度图像的实例

问题: 我正尝试使用matplotlib读取RGB图像并将其转换为灰度。 在matlab中,我使用这个: img = rgb2gray(imread('image.png'));...

使用Python的Turtle绘制哆啦A梦实例

使用Python的Turtle绘制哆啦A梦实例

这是我几年前为了练习python的turtle库而画的,今天翻出了代码,分享给大家。 这是我初学python时画的,当时还没有面向对象的概念,也没有采取类方法之类,纯原始手工,供大家参考...

python list语法学习(带例子)

创建:list = [5,7,9]取值和改值:list[1] = list[1] * 5列表尾插入:list.append(4)去掉第0个值并返回第0个值的数值:list.pop(0)去...

python利用itertools生成密码字典并多线程撞库破解rar密码

脚本功能: 利用itertools生成密码字典(迭代器形式) 多线程并发从密码字典中取出密码进行验证 验证成功后把密码写入文件中保存 #!/usr/bin/env...