[英]legends on seaborn kde plot
我不知道如何将传说放在 seaborn kde 情节上。
uses = df.primary_use.unique()
plt.figure(figsize=(7,7))
ax = plt.axes()
plt.legend(uses)
for use in uses:
sns.kdeplot(df[df['primary_use'] == use]['wind_speed'], ax=ax)
在此处查看输出:
uses
数组看起来像:
array(['Education', 'Lodging/residential', 'Office',
'Entertainment/public assembly', 'Public services'], dtype=object)
uses
是传说应该是什么,但它为每个情节放置了wind_speed
试试这个,使用label
参数:
for use in uses:
sns.kdeplot(df[df['primary_use'] == use]['wind_speed'], ax=ax, label=use)
我的 MCVE:
df = pd.DataFrame(index=np.random.choice(['a','b','c'], 100), data=np.random.randint(0,100,(100)))
df=df.rename_axis('use').reset_index()
fig, ax = plt.subplots()
use=['a','b','c']
for u in use:
sns.kdeplot(df[df['use'] == u][0], ax=ax, label=u)
输出:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.