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

相关文章

pybind11和numpy进行交互的方法

使用一个遵循buffer protocol的对象就可以和numpy交互了. 这个buffer_protocol要有哪些东西呢? 要有如下接口: struct buffer_i...

numpy:np.newaxis 实现将行向量转换成列向量

np.newaxis 新增一个轴 如何将数组[0,1,2]转换成列向量 用ndarray[: , np.newaxis] 代码实质就是将原本的(0,1,2)移到行上,然后新增一列 其实...

Python3利用Dlib实现摄像头实时人脸检测和平铺显示示例

Python3利用Dlib实现摄像头实时人脸检测和平铺显示示例

1. 引言 在某些场景下,我们不仅需要进行实时人脸检测追踪,还要进行再加工;这里进行摄像头实时人脸检测,并对于实时检测的人脸进行初步提取; 单个/多个人脸检测,并依次在摄像头窗口,实时平...

python 读取摄像头数据并保存的实例

如下所示: import cv2 cap = cv2.VideoCapture(0) k = 0 while k != 27: # esc ret, img = cap.re...

Pytorch反向求导更新网络参数的方法

方法一:手动计算变量的梯度,然后更新梯度 import torch from torch.autograd import Variable # 定义参数 w1 = Variable(...