[Matplotlib-users] LaTeX rendering

Stefano Gragnani stefano.gragnani at gmail.com
Tue Mar 12 13:36:01 EDT 2019


Hi,

My system is a MacBook Pro (i9 processor) with macOS Mojave Version 10.14.3, I have installed Matplotlib version 3.0.2 and what
I want to do is use an external TeX renderer but I always get: FileNotFoundError: [Errno 2] No such file or directory: 'latex': ‘latex’.

I get the aforementioned message, for example, trying to execute the following code:

"""
import numpy as np
import matplotlib.pyplot as plt


# Example data
t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(4 * np.pi * t) + 2

plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.plot(t, s)

plt.xlabel(r'\textbf{time} (s)')
plt.ylabel(r'\textit{voltage} (mV)',fontsize=16)
plt.title(r"\TeX\ is Number "
          r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
          fontsize=16, color='gray')
# Make room for the ridiculously large title.
plt.subplots_adjust(top=0.8)

plt.savefig('tex_demo')
plt.show()


I have installed MacTex and also MiKTek with their installers and Ghostscript with Home-brew. I use Spyder installed with Conda.
Using Mathtext everything is alright.
In which directory Matplotlib expect to find the directory ‘latex’?

Thank you all
Stefano


More information about the Matplotlib-users mailing list