user9886
user9886

Reputation: 311

How do I get rid of these artifacts (matplotlib with LaTeX)

When running the following minimal example I get strange J-shaped artifacts in the LaTeX-rendered expressions.

import matplotlib.pyplot as plt
from matplotlib import rc

rc('font',**{'family':'serif','serif':['Times']})
rc('text', usetex=True)
rc(('xtick','ytick','axes'), labelsize=12.0)
rc(('legend'), fontsize=8.0)

fig=plt.figure(figsize=(4,3))
ax1 = fig.add_subplot(111)

ax1.plot([0,1],[0,1],label=r'$\propto x^1$')
ax1.set_xlabel(r'$x$')
ax1.set_ylabel(r'$\sum_i \chi_i$')

ax1.legend()

fig.tight_layout()
plt.savefig('minimal.pdf')

Output: minimal example

How can I get rid of them?

Upvotes: 3

Views: 252

Answers (1)

user9886
user9886

Reputation: 311

As Joe Kington pointed out in his comment the way to get rid of the artefacts is to use a font that has the correct symbols.

In the minimal example removal of rc('font',**{'family':'serif','serif':['Times']}) fixes the problem.

Upvotes: 1

Related Questions