网络编程
位置:首页>> 网络编程>> Python编程>> Matplotlib 生成不同大小的subplots实例

Matplotlib 生成不同大小的subplots实例

作者:隔壁的老王  发布时间:2022-12-22 03:16:26 

标签:Matplotlib,subplots,大小

在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实例

来源:https://blog.csdn.net/xiaosebi1111/article/details/50617433

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com