我试图在matplotlib中创建一个所有标签都在LaTeX中的地块。我在Fedora 36上使用木星笔记本,使用!pip install latex
安装!pip install latex
。这是我的节目:
# 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()
然而,我收到了这个错误:
RuntimeError: Failed to process string with tex because latex could not be found
我在这里错过了什么?
发布于 2022-10-14 22:08:41
matplotlib
不依赖于python库latex
;相反,它依赖于LaTeX iself。您需要安装LaTeX,请参阅乳胶::软呢帽。因为您只希望这样做来呈现matplotlib
标签,所以请尝试如下:
sudo dnf install texlive-scheme-basic
如果这还不够,您可以安装texlive-scheme-medium
或texlive-scheme-full
。
https://stackoverflow.com/questions/74074659
复制相似问题