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

相关文章

react+django清除浏览器缓存的几种方法小结

一. meta方法 打包好的入口index.html头部加入 <META HTTP-EQUIV="pragma" CONTENT="no-cache"> <MET...

python中with语句结合上下文管理器操作详解

前言 所谓上下文管理器即在一个类中重写了__enter__方法和__exit__方法的类就可以成为上下文管理器类。 我们可以通过with语句结合上下文管理器简化一些操作。 使用with语...

python3下pygame如何实现显示中文

python3下pygame如何实现显示中文

这篇文章主要介绍了python3下pygame如何实现显示中文,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1.先看代码: im...

python dataframe astype 字段类型转换方法

使用astype实现dataframe字段类型转换 # -*- coding: UTF-8 -*- import pandas as pd df = pd.DataFrame([{'...

django删除表重建的实现方法

正确的方法如下: 先到数据库把表删掉:drop table 注释django中对应的Model 执行以下命令: python manage.py makemigrations p...