我需要在Python中显示dataframe变量的直方图,我需要显示有多少人拥有一张音乐专辑的直方图。我做到了:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()
_ = plt.hist(agrupa['have'])
_ = plt.xlabel('Albumes')
_ = plt.ylabel('Número de álbumes que tienen los usuarios')
plt.show()
我的问题是轴不对。我必须在x轴上显示相册,但我得到了一个错误
IIUC,我认为你正在寻找这样的东西,你可以通过
bar
绘图,使用pandas
和matplotlib
本身,而不需要seaborn:输出:
This Question can only be answered if you tell us with which tool you want to use.
我可以给你一些建议:
实际上,您也可以在不使用某些工具或模块的情况下使用Python本身。你知道吗
我建议您使用matplotlib,因为它比纯python更简单
摘要 我不知道你是否知道matplotlib是什么,如果不知道我会告诉你
Matplotlib是Python的一个框架,您可以在其中绘制直方图、曲线和图表。 它实际上用于数据可视化 有关更多信息,请访问此网站:https://matplotlib.org/ 对于直方图:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.hist.html
相关问题 更多 >
编程相关推荐