[英]Plotting histogram in Python with frequency percentage
我有一個評級列表,我正在為其繪制直方圖。 在左側(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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.