简体   繁体   中英

Error when saving figure as eps in Python Matplotlib

I'm trying to save a figure in the eps format using the following code:

plt.savefig("test.eps", format="eps")

but I get the error:

File "C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.py", line      258, in set_linewidth
self._pswriter.write("%1.3f setlinewidth\n"%linewidth)

TypeError: float argument required, not str

How do I fix this? I have Matplotlib 1.3.1

I figured out the issue just now. It seems that when you save figures as eps, you need to make sure that all figure properties are floats. I had a command 'linewidth = 1'. It needs to be 'linewidth=1.0'. Then it works. Strange that other formats such as svg work without issues.

Thanks!

Emmanuel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM