问题描述
查看以下代码
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
根据此处,参数可以是数值或字符串.但是,我测试了两者.标签字体权重似乎与[0,550]中的字体权重参数相同,在[551,1000]范围内变为粗体.另外, semibold
和 bold
似乎具有相同的字体粗细.
Accoding to here, the paramater can be a numeric value or a string. However, I tested both. It seems that label fontweight is the same for fontweight params in [0, 550], in the range [551 , 1000], it becomes bold. Also, semibold
, and bold
seem to have the same fontweight.
我假设 fontweight 是线性变化的,但显然不是.任何人都可以解释为什么会这样?
I assume a linear change of fontweight, but apparently it is NOT. Anyone can explain why it is so?
推荐答案
通常情况下,一种字体只有有限数量的字重,例如Regular
、Medium
、Bold
等.字体粗细不是无限的.
Normally, a font only has limited number of font weight, such as Regular
, Medium
, Bold
, etc. The font weights are not infinite.
数值与有限字体粗细有对应关系.如需了解详情,请参阅此处.
There is correspondence between the numeric value and finite font weight. For more details, see here.
这篇关于Matplotlib刻度标签的字体重量仅限于几个选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!