3

I have a Font problem in eps-files from matplotlib.

The font show correctly in die eps file, but when I paste the file in Microsoft Word, it doesnt Show the text (Labels, ticks, title...)

I already tryed to change the maplotlib.rcParams because that was the solution for other problems with text in eps files, but nothing worked.

EDIT: already changed matplotlib.use("xxx") too, did not help.

my code:

# -*- coding: utf-8 -*-

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

a = np.array([[1,2,3],[4,5,6],[7,8,9]])

fig = plt.figure(figsize=(12,10))
ax = fig.add_subplot(111, projection='3d')

plt.title("lalala",family='Courier New')
x = range(len(a))
y = range(len(a))
X,Y = np.meshgrid(x,y)
Z = a

ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")

ax.plot_surface(X,Y,Z, cmap=plt.cm.Reds, cstride=1, rstride=1,alpha=0.3)

plt.savefig("texttestqua.eps")
plt.show()

is it possible to "draw" the text in the eps file? So that the text is not a "font" but just graphic-vectors?

Hubschr
  • 1,285
  • 6
  • 18
  • 35

1 Answers1

0

I am not entirely sure if your problem stems from the inability of matplotlib to save your eps correctly or the inability of Microsoft Word to load vector graphics other than emf/wmf... Nonetheless, I am giving it a try...

There are quite a lot of backends (GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG), have you tried them all or at least a plausible subset? Does it work for example with PS?


I am using the TkAgg backend here and your script produces the following output for me: screenshoted_eps_with_text


but when I paste the file in Microsoft Word, it doesnt Show the text (Labels, ticks, title...)

Afaik Microsoft Word does not support vector graphics natively unless it is emf. See this link for further guidance.

If that does not solve your problem, please consider formulating an explicit problem.

tafaust
  • 1,457
  • 16
  • 32