python - 在 hist() 的 python Matplotlib.pyplot 中,我想选择 xlabel 和 ylabel 值
问题描述
我使用了这些库:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
我导入数据,然后选择我想学习的内容
df=df15[['Country','Happiness Score']][0:5]
df
输出是
Country Happiness Score
0 Switzerland 7.587
1 Iceland 7.561
2 Denmark 7.527
3 Norway 7.522
4 Canada 7.427
之后我想使用 plt.hist() 我想成为 x=Country 和 y=Happiness Score??
解决方案
直方图用于查看单个变量的分布。在你的情况下是幸福分数。在直方图中将 x 标签作为“国家”是没有意义的。
使用 x=Country 和 y=Happiness Score 时,条形字符会更有意义。
推荐阅读
- html - flexbox的特定定位问题
- java - 如何使用 Smack 4 解析 Muc Sub 事件包
- python - Django:如何在不重新加载页面的情况下提交表单并在同一页面上接收结果
- unity3d - 如何更改对象的中心以正确旋转?
- vb.net - 使两个组合框的输入从 csv 文件中搜索、读取和显示数据
- css - 更改传入字符串中特定单词的颜色
- algorithm - 从城市 1 到达城市 N 的最短时间
- r - 使用循环将矩阵转换为另一个矩阵
- asp.net-mvc - 在从 Swagger 2.0 到 3.0 的 swagger 更改中将整数列表发送到 API 端点
- excel - Excel:自动化 COUNTIF(基于另一个表)