python画图后如何保存?很多人都不太了解,今天小编为了让大家更加了解python画图的保存方法,所以给大家总结了以下内容,一起往下看吧。

1、使用matplotlib画图保存方法:
首先,import头文件如下:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.pyplot import plot,savefig画图:
fig, ax = plt.subplots(figsize=(12, 12))
ax.imshow(im, aspect='equal') #im是要显示的图像
保存图片:
savefig("D:/1.jpg")展示图片:
plt.show()
2、turtle生成图片保存
代码示例如下:
from Tkinter import *
from turtle import *
import turtle
forward(100)
ts = turtle.getscreen()
ts.getcanvas().postscript(file="duck.eps") #.eps文件即postscript脚本
以上就是python画图后如何保存的详细内容了,看完之后是否有所收获呢?如果想了解更多相关内容,欢迎来天达云行业资讯!