在Python中用频率百分比绘制直方图
我有一个评分列表,我正在绘制一个直方图。在左侧(y轴)显示频率计数,是否有方法显示基于流量的百分比在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
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的作业。