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从ZabbixAPI获取信息及实现Zabbix-API 监控的方法

Python从ZabbixAPI获取信息及实现Zabbix-API 监控的方法

Python编写从ZabbixAPI获取信息 此脚本用Python3.6执行是OK的。 # -*- coding: utf-8 -*- import json import urll...

Python实现的多线程http压力测试代码

本文实例讲述了Python实现的多线程http压力测试代码。分享给大家供大家参考,具体如下: # Python version 3.3 __author__ = 'Toil' imp...

python类和函数中使用静态变量的方法

本文实例讲述了python类和函数中使用静态变量的方法。分享给大家供大家参考。具体分析如下: 在python的类和函数(包括λ方法)中使用静态变量似乎是件不可能[Nothing is i...

使用Python生成XML的方法实例

本文实例讲述了使用Python生成XML的方法。分享给大家供大家参考,具体如下: 1. bookstore.py #encoding:utf-8 ''' 根据一个给定的XML Sch...

Python实现简单截取中文字符串的方法

本文实例讲述了Python实现简单截取中文字符串的方法。分享给大家供大家参考。具体如下: web应用难免会截取字符串的需求,Python中截取英文很容易: >>>...