Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中用频率百分比绘制直方图_Python_Matplotlib_Graph - Fatal编程技术网

在Python中用频率百分比绘制直方图

在Python中用频率百分比绘制直方图,python,matplotlib,graph,Python,Matplotlib,Graph,我有一个评分列表,我正在绘制一个直方图。在左侧(y轴)显示频率计数,是否有方法显示基于流量的百分比 fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ax.hist(item['ratings'], bins = 5) ax.legend() ax.set_title("Ratings Frequency") ax.set_xlabel("Ratings") ax.set_ylabel("frequ

我有一个评分列表,我正在绘制一个直方图。在左侧(y轴)显示频率计数,是否有方法显示基于流量的百分比

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.hist(item['ratings'], bins = 5)
ax.legend()
ax.set_title("Ratings Frequency")
ax.set_xlabel("Ratings")
ax.set_ylabel("frequency")
ax.axhline(y=0, linestyle='--', color='k')

您可以使用countplot尝试使用seaborn库,这将使数据可视化变得非常容易

import seaborn as sns   
sns.countplot()

谢谢,但这是一个我们只能使用matplotlib的作业。