我想知道如何使用對數圖來可視化串列中元素的頻率,例如:
my_list=[1,2,3,3,3,4,1,2,5,2,10,4,5,3,3,3,2,1]
我使用直方圖繪制資料:
plt.hist(my_list, label='Frequency Distribution of matches')
plt.legend()
plt.ylabel('Frequency')
但最好將其可視化為日志日志。
uj5u.com熱心網友回復:

如果您想要等寬條形,請定義bins為10 ** edges:
start, stop = np.log10(min(my_list)), np.log10(max(my_list))
bins = 10 ** np.linspace(start, stop, 10)
plt.hist(my_list, log=True, bins=bins)
ax.set_xscale('log')

要獲得頻率的對數對數線圖,請使用
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/364609.html
標籤:Python matplotlib
