// backend to write a file.
with cbook._setattr_cm(tempfile, tempdir=str(base_tempdir)):
// usetex results in the latex call, which does not like the ~
plt.rc("text", usetex=True)
plt.plot([1, 2, 3, 4])
plt.xlabel(r"\textbf{time} (s)")
output_eps = os.path.join(str(base_tempdir), "tex_demo.eps")
// use the PS backend to write the file...
After Change
// backend to write a file.
with cbook._setattr_cm(tempfile, tempdir=str(base_tempdir)):
// usetex results in the latex call, which does not like the ~
mpl.rcParams["text.usetex"] = True
plt.plot([1, 2, 3, 4])
plt.xlabel(r"\textbf{time} (s)")
// use the PS backend to write the file...
plt.savefig(base_tempdir / "tex_demo.eps", format="ps")