[英]histogram with one column per each value in R
你可以使用 barplot 和 table 函數
barplot(table(test_data))
您可以使用nclass
或breaks
參數來調整 bin 的數量。
test_data = c(1,1,1,2,2,3,3,4)
hist(test_data,breaks=5)
hist(test_data,nclass=5)
事實上,python 也是一樣的。 參數是bins
。 默認值為10(根據this page )
所以如果你修改它,我們會得到一個不同的 plot
import matplotlib.pyplot as plt
test_data = [1,1,1,2,2,3,3,4]
plt.hist(test_data,bins=4)
plt.show()
你得到
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.