Default monospace font with text.usetex in matplotlib.

huangapple go评论74阅读模式
英文:

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()

Default monospace font with text.usetex in matplotlib.

之后:

...
rc('text', usetex=True)
...

Default monospace font with text.usetex in matplotlib.

我尝试使用'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()

Default monospace font with text.usetex in matplotlib.
After:

...
rc('text', usetex=True)
...

Default monospace font with text.usetex in matplotlib.

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.

huangapple
  • 本文由 发表于 2023年3月15日 21:22:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75745302.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定