首页 > 编程 > Python > 正文

Matplotlib 生成不同大小的subplots实例

2019-11-25 14:40:42
字体:
来源:转载
供稿:网友

在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实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表