美文网首页TensorFlow@IT·互联网程序员
matplotlib的基本用法(十七)——保存figure

matplotlib的基本用法(十七)——保存figure

作者: SnailTyan | 来源:发表于2017-05-10 21:06 被阅读83次

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

本文主要介绍matplotlib的一些用法。

  • Demo
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')

# 定义数据
x = np.arange(0, 10, 0.1)
y = 0.05 * x ** 2

#绘制图像
plt.plot(x, y)

# 设置坐标轴
plt.xlabel('x data')
plt.ylabel('y data')

# 默认保存为png格式
plt.savefig('test')
  • 结果

在文件夹下可看到test.png,如图:

图像

相关文章

网友评论

    本文标题:matplotlib的基本用法(十七)——保存figure

    本文链接:https://www.haomeiwen.com/subject/vrxntxtx.html