【发布时间】:2014-09-10 17:41:44
【问题描述】:
我想知道 matplotlib 中是否有一种方法可以放置直方图以覆盖我在下图中的散点图所具有的点的高度?我只是想办法制作一个直方图来覆盖轴上的 10 个 bin。这是我到目前为止的代码:
bglstat = np.array([9.0, 10.0, 2.0, 7.0, 7.0, 4.0])
candyn = np.array([2.0, 2.0, 1.0, 1.0, 1.0, 3.0, 1.0, 2.0, 1.0, 1.0])
candid = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0])
fig = plt.figure()
a2 = fig.add_subplot(111)
a2.scatter(candid, candyn, color='red')
a2.set_xlabel("Candidate Bulgeless Galaxy ID #")
a2.set_ylabel("Classified as Bulgeless")
a2.set_xticks([1,2,3,4,5,6,7,8,9,10])
plt.show()
【问题讨论】:
标签: python matplotlib histogram scatter-plot