這裏是我的代碼片段繪製bincounts:如何強制PyPlot顯示空箱在柱狀圖
pos = np.arange(len(ranger))
print pos
width = 1.0 # gives histogram aspect to the bar diagram
ax = plt.axes()
ax.set_xticks(pos + (width/2))
ax.set_xticklabels(ranger)
plt.bar(pos, freq, width, color='b',)
plt.savefig("binplotdisease/"+key+"_binplot.png")
plt.close()
遊俠是0.17。然而,當我繪製一些數據時,我發現如果例如只有一個數爲9而沒有其他數(其餘爲0),那麼只有9個出現在圖中。爲了我的工作目的,我希望能夠看到從0到17的整個空間,以便我能更好地查看趨勢。如何更改繪圖設置,以便看到空箱?
你能正確地重新表述您的問題。你的空箱子是什麼意思?首先當空箱子時,你怎麼能顯示一個箱子? – ThePredator