我在Jupyter笔记本上有以下数据框,它使用seaborn barplot绘制:
day_index avg_duration trips
0 0 708.852242 114586
1 1 676.702190 120936
2 2 684.572677 118882
3 3 708.925340 117868
4 4 781.767476 108036
5 5 1626.575057 43740
6 6 1729.155673 37508
daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday\n', \
'Friday', 'Saturday', 'Sunday']
plt.figure(figsize=(16,10));
sns.set_style('ticks')
ax = sns.barplot(data=dfGroupedAgg, \
x='day_index', \
y='avg_duration', \
hue='trips', \
palette=sns.color_palette("Reds_d", n_colors=7, desat=1))
ax.set_xlabel("Week Days", fontsize=18, alpha=0.8)
ax.set_ylabel("Duration (seconds)", fontsize=18, alpha=0.8)
ax.set_title("Week's average Trip Duration", fontsize=24)
ax.set_xticklabels(daysOfWeek, fontsize=16)
ax.legend(fontsize=15)
sns.despine()
plt.show()
从图中可以看出,这些条线与x掼u标签不匹配,而且非常薄。
如果我删除了hue='trips'
部分,这是一个已知的seaborn问题。
尽管在可视化中显示旅行次数非常重要,那么:是否有办法在seaborn周围(可能直接使用matplotlib)添加色调属性?
目前没有回答
相关问题 更多 >
编程相关推荐