Matplotlib 生成不同大小的subplots实例

yipeiwu_com6年前Python基础

在Matplotlib实际使用中会有生成不同大小subplots的需求。

import numpy as np 
import matplotlib.pyplot as plt 
from matplotlib import gridspec 
x = np.arange(0, 10, 0.2) 
y = np.sin(x) 
fig = plt.figure(figsize=(8, 6)) 
gs = gridspec.GridSpec(1, 2, width_ratios=[3, 1]) 
ax0 = plt.subplot(gs[0]) 
ax0.plot(x, y) 
ax1 = plt.subplot(gs[1]) 
ax1.plot(y, x) 
plt.tight_layout() 
plt.savefig(‘grid_figure.pdf')

以上这篇Matplotlib 生成不同大小的subplots实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python 使用shutil复制图片的例子

主要步骤: import shutil shutil.copyfile(old_image,new_image) 完整: 这里要做的是,将原图片复制10份,为防止原文件夹中有很...

python使用电子邮件模块smtplib的方法

python使用电子邮件模块smtplib的方法

Smptp类定义:smtplib.SMTP(host[,port[,local_hostname[,,timeout]]]),作为SMTP的构造函数,功能是与smtp服务器建立连接,在连...

django基础之数据库操作方法(详解)

django基础之数据库操作方法(详解)

Django 自称是“最适合开发有限期的完美WEB框架”。本文参考《Django web开发指南》,快速搭建一个blog 出来,在中间涉及诸多知识点,这里不会详细说明,如果你是第一次接触...

用Python编写简单的定时器的方法

下面介绍以threading模块来实现定时器的方法。 首先介绍一个最简单实现: import threading def say_sth(str): print str t...

Pytorch中的VGG实现修改最后一层FC

https://discuss.pytorch.org/t/how-to-modify-the-final-fc-layer-based-on-the-torch-model/766/1...