How to save the picture after drawing in python

Release: 2019-07-05 09:46:24
Original
20737 people have browsed it

How to save the picture after drawing in python

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
Copy after login

Drawing:

fig, ax = plt.subplots(figsize=(12, 12))
ax.imshow(im, aspect='equal') #im是要显示的图像
Copy after login

Save the picture:

savefig("D:/1.jpg")
Copy after login

Display the picture:

plt.show()
Copy after login

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脚本
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template