from sklearn.datasets import load_irisimport matplotlib.pyplot as pltiris = load_iris()s = iris.data[iris.target == 1, 3]plt.hist(s)plt.show()s為ndarray類型,具體數(shù)據(jù)如下:[1.4 1.5 1.5 1.3 1.5 1.3 1.6 1. 1.3 1.4 1. 1.5 1. 1.4 1.3 1.4 1.5 1.1.5 1.1 1.8 1.3 1.5 1.2 1.3 1.4 1.4 1.7 1.5 1. 1.1 1. 1.2 1.6 1.5 1.61.5 1.3 1.3 1.3 1.2 1.4 1.2 1. 1.3 1.2 1.3 1.3 1.1 1.3]1.有7次,1.1有3次,1.2有5次,1.3有13次,1.4有5次,1.5有10次,1.6有3次,1.7和1.8都各有一次。畫出來的圖如下:為什么和刻度不對齊?而且1.3和1.4之間為什么會有空隙?
為什么用matplotlib的hist方法畫出的直方圖坐標(biāo)刻度不對齊?
ibeautiful
2019-02-05 20:18:37