好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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相关技术文章,请访问Python教程栏目进行学习!

以上就是python画图后怎么保存的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于python画图后怎么保存的详细内容...

  阅读:51次