1

If I execute the following code, the resulting eps-file does not contain tick labels or axes labels.

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0,2*np.pi,100)
y = np.sin(x)

plt.figure()
plt.plot(x,y)
plt.xlabel('x')
plt.ylabel('sin(x)')
plt.savefig('image.eps', format='eps')

As some additional information: I am using version 4.3.0 of the anaconda distribution and execute my code in Spyder 3.1..2. I tested the two backends TkAgg and Qt5Agg, the result is the same for both.

Any ideas how I can get a correct eps-file?

Alternatively: which other vector graphics format could I use if I want to import into MS Word later?

rmnboss
  • 73
  • 6
  • When I run this, I get the correct eps file with text, etc. – Willem Van Onsem Mar 10 '17 at 15:58
  • Possible duplicate of [Matplotlib labels/titles disappear when exporting in eps format](http://stackoverflow.com/questions/20817455/matplotlib-labels-titles-disappear-when-exporting-in-eps-format) – tahesse Mar 10 '17 at 16:18

1 Answers1

0

So I think that you will find your answer here: https://stackoverflow.com/a/20817722/2402281


It might be the case that your matplotlib backend does not support that operation. You can change the matplotlib backend as follows:

# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
# CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG
import matplotlib
matplotlib.use('PS')

or in the matplotlibrc (see the documentation).

Community
  • 1
  • 1
tahesse
  • 1,121
  • 8
  • 23
  • Ah well… I am sorry that did not help. The odds are that the issue is related to your OS or some missing libs because I fail to reproduce the issue using Python 3.6.0 under Linux 4.9.11-1-ARCH GNU/Linux. For the "Alternatively" part in your question, you might have a look at this SO thread: http://stackoverflow.com/a/40250694/2402281 – tahesse Mar 14 '17 at 15:38