How to get rid of these artifacts (matplotlib with LaTeX)

When I run the following minimal example, I get weird J-shaped artifacts in LaTeX 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?

+3
source share
1 answer

As Joe Kington noted in his comment, a way to get rid of artifacts is to use a font with the correct characters.

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

+1
source

All Articles