1. How to save drawing using matplotlib:
First, import the header file as follows:
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.pyplot import plot,savefig
Drawing:
fig, ax = plt.subplots(figsize=(12, 12)) ax.imshow(im, aspect='equal') #im是要显示的图像
Save the picture:
savefig("D:/1.jpg")
Display the picture:
plt.show()
2. Save the turtle generated picture
The code example is as follows:
from Tkinter import * from turtle import * import turtle forward(100) ts = turtle.getscreen() ts.getcanvas().postscript(file="duck.eps") #.eps文件即postscript脚本
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of How to save the picture after drawing in python. For more information, please follow other related articles on the PHP Chinese website!