File/directory not found when trying to render matplotlib text with LaTeX

Viewed 2584

I'm trying to render text in matplotlib using LaTeX, so that I can include native-looking plots in my LaTeX documents, as described here: https://matplotlib.org/1.3.1/users/usetex.html

I have LaTeX, dvipng and Ghostscript installed, and I've checked the executables are in my PATH (as specified in the matplotlib documentation) but when I run the following test it returns

  File "/Users/wilf/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)

FileNotFoundError: [Errno 2] No such file or directory: 'latex': 'latex'

The test code is just

import matplotlib as plt
plt.rc('text', usetex=True)
plt.rc('font', family='serif')

plt.pyplot.plot([1, 2, 3], [1, 2, 3])
plt.pyplot.xlabel('x')
plt.pyplot.ylabel('y')

I'm not sure why it gives me this error, or how I can fix it.

0 Answers
Related