如何将折线图更改为条形图?

时间:2018-12-12 21:14:44

标签: python charts histogram

有人知道如何将line chart更改为bar chart吗?

有一个代码:

plt.figure(figsize = (18,12))
plt.subplot(2,2,1)
img = skimage.data.chelsea()
color = ('r','g','b')
for i,col in enumerate(color):
    histr = cv2.calcHist([img],[i],None,[256],[0,256])
    plt.plot(histr,color = col)
    plt.xlim([0,256])
labels= ["red","green", "blue"]
plt.legend(labels)
plt.show()

1 个答案:

答案 0 :(得分:1)

更改

import username-packagename

plt.plot(histr, color = col)

matplotlib bar chart documentation