gpt4 book ai didi

python - 仅更新 title、xlabel 或 ylabel 的字体大小

转载 作者:太空宇宙 更新时间:2023-11-03 12:24:16 24 4
gpt4 key购买 nike

我知道我们有以下方法来添加/更改xlabel、ylabel和标题:

fig.suptitle('test title', fontsize=20)
plt.xlabel('xlabel', fontsize=20)
plt.ylabel('ylabel', fontsize=20)

但是如果我不想更改任何这些属性的实际字符串而只想更改字体大小?

如果我单独使用 fontsize 参数尝试这些函数中的任何一个,它都不会工作:

plt.xlabel(fontsize=20)

我得到:

TypeError: xlabel() takes at least 1 argument (0 given)

最佳答案

有一个set_fontsize方法:

plt.plot(range(10), range(10))
plt.xlabel('To change it', fontsize=20)
plt.ylabel('To keep it', fontsize=20)
plt.gca().xaxis.get_label().set_fontsize(50)

enter image description here

关于python - 仅更新 title、xlabel 或 ylabel 的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22544637/

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