看下面的代码
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.0001, 30, 1000)
y = np.sin(x)/x
fig, ax = plt.subplots(1, 1)
ax.plot(x, y)
ax.tick_params(which="major", labelsize=14, width=1.3)
for label in ax.get_xticklabels():
label.set_fontweight(550) # If change to 551, label will be bold-like
根据here ,参数可以是数值或字符串。不过,我测试了两者。看起来标签 fontweight 与 [0, 550] 中的 fontweight 参数相同,在 [551 , 1000] 范围内,它变成粗体。此外,semibold
和 bold
似乎具有相同的字体粗细。
我假设字体粗细是线性变化的,但显然事实并非如此。任何人都可以解释为什么会这样吗?
一般情况下,一种字体只有有限的几种字体粗细,如Regular
、Medium
、Bold
等。字体粗细为不是无限的。
数值与有限字体粗细之间存在对应关系。更多详情请参见here .
我是一名优秀的程序员,十分优秀!