python画图后如何保存
发布时间:2020-04-15 14:24:48
来源:亿速云
阅读:342
作者:小新
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画图后如何保存的详细内容了,看完之后是否有所收获呢?如果想了解更多相关内容,欢迎来亿速云行业资讯!