英文:
Default monospace font with text.usetex in matplotlib
问题
在我的绘图中,我需要使用rc('text', usetex=True)
,我注意到它改变了图中使用的字体。
在使用之前:
from matplotlib import rc
import matplotlib.pyplot as plt
rc('font', **{'family': 'monospace', 'monospace': 'Deja Vu Sans Mono', 'size': 25})
rc('text', usetex=False)
plt.clf()
x = [0, 1, 2]
y = [1, 1, 1]
plt.plot(x, y)
plt.ylabel(r"This is $y=1$", size=25)
plt.xlabel("This is x", size=25)
plt.show()
之后:
...
rc('text', usetex=True)
...
我尝试使用'mathtext.*'
的rc属性,但找不到可以使这两个输出对齐的设置。有什么要注意的吗?
英文:
I need to use rc('text', usetex=True)
in one of my plots, and I noticed that it changes the fonts that are used in the figure.
Before:
from matplotlib import rc
import matplotlib.pyplot as plt
rc('font', **{'family': 'monospace', 'monospace': 'Deja Vu Sans Mono', 'size': 25})
rc('text', usetex=False)
plt.clf()
x = [0,1,2]
y = [1,1,1]
plt.plot(x,y)
plt.ylabel(r"This is $y=1$", size=25)
plt.xlabel(r"This is x", size=25)
plt.show()
...
rc('text', usetex=True)
...
I tried working with the 'mathtext.*'
rc properties but I could find the settings that can align these two outputs. Is there a catch?
答案1
得分: 1
如在使用LaTeX文档中提到,"只支持少量字体系列"。<br> 您可以检查可用的字体系列,但对于monospace
系列,仅支持Computer Modern Typewriter和Courier。
英文:
As mentioned in the Text rendering with LaTeX doc, "only a small number of font families are supported". <br> I'll let you check the available font families but for the monospace
family, only Computer Modern Typewriter and Courier are supported.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论