我制作了一个可复制的小程序,在那里你会看到
title
以粗体显示,但
label
使用普通字体:
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
observed = np.array([28, 15, 21, 23, 17, 22, 19, 19, 24, 27, 20, 21, 25, 25, 16, 20, 23])
fig, ax = plt.subplots(figsize=(4, 2))
sns.histplot(ax = ax, x = list(observed), label = "observed data")
ax.set_title("Observed data", fontweight='bold')
ax.legend()
plt.show()
我试着设置
标签
通过放入相同的代码以粗体显示
fontweight='bold'
(在之后
label =
学期
在…内
这个
sns.histplot
指令,但这会导致错误:
sns.histplot(ax = ax, x = list(observed), label = "observed data", fontweight='bold')
好吧,我承认这不是一个非常明智的尝试,但我不知道如何以简单的方式将标签加粗。。。
有人能帮我这么做吗?