gpt4 book ai didi

python - Matplotlib 刻度标签字体粗细仅限于几个选项

转载 作者:太空宇宙 更新时间:2023-11-03 21:23:03 25 4
gpt4 key购买 nike

看下面的代码

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] 范围内,它变成粗体。此外,semiboldbold 似乎具有相同的字体粗细。

我假设字体粗细是线性变化的,但显然事实并非如此。任何人都可以解释为什么会这样吗?

最佳答案

一般情况下,一种字体只有有限的几种字体粗细,如RegularMediumBold等。字体粗细为不是无限的。

数值与有限字体粗细之间存在对应关系。更多详情请参见here .

关于python - Matplotlib 刻度标签字体粗细仅限于几个选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54084806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com