目前我使用代码制作了1个直方图:
num_bins = 200 # <- number of bins for the histogram
(n, bins, patches) = plt.hist(bins, num_bins,facecolor = 'orange')
plt.title('Histogram1')
plt.xlabel('Distance')
plt.ylabel('Frequency')
label_positions = np.arange(0, 50,5)
plt.xticks(label_positions)
plt.show()
但是现在我有X和Y的列表值,所以我如何在直方图中绘制我的X和Y值。
X值:
[0.10000000000000001, 0.30000000000000004, 0.5, 0.70000000000000007, 0.90000000000000002, 1.1000000000000001, 1.3000000000000003, 1.5, 1.7000000000000002, 1.8999999999999999, 2.1000000000000001, 2.3000000000000003, 2.5, 2.7000000000000002, 2.9000000000000004, 3.1000000000000001, 3.3000000000000003, 3.5, 3.7000000000000002, 3.9000000000000004, 4.0999999999999996, 4.3000000000000007, 4.5, 4.7000000000000011, 4.9000000000000004, 5.0999999999999996, 5.3000000000000007, 5.5, 5.7000000000000011, 5.9000000000000004, 6.0999999999999996, 6.3000000000000007, 6.5, 6.7000000000000011, 6.9000000000000004, 7.0999999999999996, 7.3000000000000007, 7.5, 7.7000000000000011, 7.9000000000000004, 8.1000000000000014, 8.3000000000000007, 8.5, 8.6999999999999993, 8.9000000000000004, 9.1000000000000014, 9.3000000000000007, 9.5, 9.7000000000000011, 9.9000000000000004, 10.100000000000001, 10.300000000000001, 10.5, 10.700000000000001, 10.9, 11.100000000000001, 11.300000000000001, 11.5, 11.700000000000001, 11.9, 12.100000000000001, 12.300000000000001, 12.5, 12.700000000000001, 12.9, 13.100000000000001, 13.300000000000001, 13.5, 13.700000000000001, 13.9, 14.100000000000001, 14.300000000000001, 14.5, 14.700000000000001, 14.9, 15.100000000000001, 15.300000000000001, 15.5, 15.700000000000001, 15.9, 16.100000000000001, 16.300000000000001, 16.5, 16.700000000000003, 16.899999999999999, 17.100000000000001, 17.300000000000001, 17.5, 17.700000000000003, 17.899999999999999, 18.100000000000001, 18.300000000000001, 18.5, 18.700000000000003, 18.899999999999999, 19.100000000000001, 19.300000000000004, 19.5, 19.700000000000003, 19.899999999999999]
Y值:格式与X值相同。