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 实现二维列表转置

python 二维列表转置 def transpose(self, matrix): new_matrix = [] for i in range(len(matri...

python实现桌面托盘气泡提示

本文实例为大家分享了python实现桌面托盘气泡提示的具体代码,供大家参考,具体内容如下 # -*- encoding:utf-8 -*- ####################...

对python周期性定时器的示例详解

一、用thread实现定时器 py_timer.py文件 #!/usr/bin/python #coding:utf-8 import threading import os im...

详解python statistics模块及函数用法

本节介绍 Python 中的另一个常用模块 —— statistics模块,该模块提供了用于计算数字数据的数理统计量的函数。它包含了很多函数,具体如下表:...

python做量化投资系列之比特币初始配置

本文实例为大家分享了python比特币初始配置的具体代码,供大家参考,具体内容如下 # -*- coding: utf-8 -*- """ Created on Fri Jan...