Seaborn的定制传奇
我想在这里设置一个图例,到目前为止,有一个颜色不正确的图例,请帮我修改一下。
fig, ax = plt.subplots(figsize=(12, 6))
sns.set(style='whitegrid')
ax=sns.pointplot(data=june_avg, x='Hour', y='bike_count', color='black')
ax=sns.pointplot(data=houravg, x='Hour', y='bike_count', color='green')
plt.legend(title='Avg Bike Rent', loc='upper left', labels=['Annaul', 'June'])
ax.set(xlabel='Hour', ylabel='Bike Count')
plt.title('Annual Avg vs June Avg Rent per Hour', fontsize=17, pad=30)
plt.show()
I am trying to set a legend here, and so far got one with incorrect colors, pls help me amend this.
fig, ax = plt.subplots(figsize=(12, 6))
sns.set(style='whitegrid')
ax=sns.pointplot(data=june_avg, x='Hour', y='bike_count', color='black')
ax=sns.pointplot(data=houravg, x='Hour', y='bike_count', color='green')
plt.legend(title='Avg Bike Rent', loc='upper left', labels=['Annaul', 'June'])
ax.set(xlabel='Hour', ylabel='Bike Count')
plt.title('Annual Avg vs June Avg Rent per Hour', fontsize=17, pad=30)
plt.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是随后尝试更改传奇,而是此相关帖子也没有解决方案,我建议以某种方式组合您的两个数据范围,以便您可以使用一个
pointplot
使用hue> hue
变量:输出:输出:

Instead of trying to change the legend afterwards, which this related post also has no solution for, I would suggest to combine your two dataframes in a way so that you can have a single
pointplot
call with ahue
variable:Output:
