Home  >  Article  >  Backend Development  >  How to export eps files in python

How to export eps files in python

(*-*)浩
(*-*)浩Original
2019-07-03 12:01:0310474browse

Can be directly exported to .eps file using python. Command: plt.savefig("./plteps.eps", format='eps', dpi=1000)

How to export eps files in python

Example: (Recommended learning: Python video tutorial)

import matplotlib.pyplot as plt
from math import sin
i = [x for x in xrange(-10,10,1)]
j = [x**2 for x in i]

plt.plot(i, j, linewidth=2.0, color='r')
# plt.show()
plt.savefig('./plteps.eps', format='eps', dpi=1000)

Cannot open plt.show, otherwise, a valid eps file cannot be generated

Comment out show, and the eps file can be generated normally.

note:

The font of graphics cannot be set to Times New Roman, otherwise, it cannot be generated.

font = {'family' : 'Times New Roman', #'serif',  
        'color'  : 'black',  
        'weight' : 'normal',  
        'size'   : 35,  
        }

Although the image in .eps format is obtained in this way, there are blank spaces around it. There are two methods to remove these blanks. One method is to use gsview. On Windows, generally Will use this tool, another method is to use epstool (http://pages.cs.wisc.edu/~ghost/gsview/epstool.htm).

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to export eps files in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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