search

Home  >  Q&A  >  body text

python - 如何自动保存matplotlib生成的图片

import matplotlib.pyplot as plt
import math


x_list = range(1,20)
y_list = range(1,20)

# draw
plt.figure(figsize=(13, 7))
plt.plot(x_list, y_list, color="red", linewidth=3)
plt.xlabel("")
plt.ylabel("R")
plt.title(u"x x")
plt.legend((u"图例",))

plt.ylim(0, 30)
plt.legend()
plt.show()
PHP中文网PHP中文网2804 days ago967

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:47:16

    plt.savefig('test.png')

    reply
    0
  • Cancelreply