Issue
I am trying to create a plot in matplotlib where all the labels are in LaTeX. I am using Jupyter Notebook on Fedora 36 and installed LaTeX using !pip install latex
. Here is my program:
# importing the required module
import matplotlib.pyplot as plt
# x axis values
x = [1,2,3]
# corresponding y axis values
y = [2,4,1]
# plotting the points
plt.plot(x, y)
# naming the x axis
plt.xlabel('x - axis')
# naming the y axis
plt.ylabel('y - axis')
# giving a title to my graph
plt.title('My first graph!')
plt.rcParams.update({
"text.usetex": True,
"font.family": "monospace"})
# function to show the plot
plt.show()
Yet, I receive this error:
RuntimeError: Failed to process string with tex because latex could not be found
What am I missing here?
Solution
matplotlib
doesn't have a dependency on the python library latex
; rather, it has a dependency on LaTeX iself. You need to install LaTeX, see Latex :: Fedora Docs. Since you only want this for rendering matplotlib
labels, try this:
sudo dnf install texlive-scheme-basic
If that's not enough, you could install texlive-scheme-medium
or texlive-scheme-full
.
Answered By - pigrammer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.