python - Seaborn 条形图的简单问题
问题描述
这里的问题相对简单,但我有一个简单的数据框,如下所示:
df.head()
trigger count
0 task_appeared 8677
1 status 7410
2 task_created 4046
3 custom_field 2550
4 on_due_date 2116
我想打印出递减的 seaborn 视觉效果,以按降序显示触发器类型列表。我的代码如下:
sns.countplot(x = "trigger", data = df,palette = 'plasma')
plt.title("Trigger Popularity")
plt.ylabel("Count of Triggers")
plt.xlabel("Trigger Type")
plt.xticks(rotation=90)
但是我只是得到以下视觉效果。它没有按我原始数据框中列出的降序显示每个触发器的正确值计数。我不知道为什么 y 轴应该显示 DF 的计数列指定的值时只显示 0 到 1 的值
解决方案
您已经计算了每种触发器类型的数量
所以你可以使用barplot
sns.barplot(x="trigger", y="count", data=df)
plt.xticks(rotation=90)
plt.title("Trigger Popularity")
输出:
推荐阅读
- swift - 大标题折叠时如何呈现不同的导航标题?
- python - 确定正在使用的 list() 是内置类型还是内置函数?
- apache-kafka - 组名不是轮询数据
- django - python manage.py migrate 不会连接到另一个 docker 容器中的单独 postgresql
- .net - 哪个 ORM 可以在带有 Oracle 数据库的 .Net Web API 中使用?
- wordpress - 相同角色的用户如何编辑其他帖子
- python - 构建使用 Adamchick 系列计算 pi 的逻辑图
- ios - 使用 takePictureAsync 时,如何在 iOS 上更快地上传图像?
- excel - 如何验证是否通过量角器脚本打开了 excel 文件?
- xamarin - 制作 HTTPClient PostAsync 和 GetAsync 的流行方法?