使用Matplotlib从iPython笔记本中将图形另存为文件
要将图形另存为来自iPython的文件,我们可以采取以下步骤-
创建一个新图或激活一个现有图。
使用add_axes()方法将轴添加到图形中。
绘制给定列表。
使用savefig()方法保存图。
示例
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = fig.add_axes([1, 1, 1, 1])
plt.plot([1, 2])
plt.savefig('test.png', bbox_inches='tight')输出结果当我们执行代码时,它将以下图另存为“test.png”。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下