3

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

Alex Riley
  • 169,130
  • 45
  • 262
  • 238
Emmanuel Sunil
  • 243
  • 4
  • 16

1 Answers1

7

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

Emmanuel Sunil
  • 243
  • 4
  • 16