Can be directly exported to .eps file using python. Command: plt.savefig("./plteps.eps", format='eps', dpi=1000)
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 thePython Tutorialcolumn 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!