本文實(shí)例主要向大家分享了一個Python+matplotlib+numpy繪制精美的條形統(tǒng)計圖的代碼,效果展示如下:

完整代碼如下:
import matplotlib.pyplot as pltfrom numpy import arangefrom numpy.random import randdef gbar(ax, x, y, width=0.5, bottom=0):  X = [[.6, .6], [.7, .7]]  for left, top in zip(x, y):    right = left + width    ax.imshow(X, interpolation='bicubic', cmap=plt.cm.Blues,         extent=(left, right, bottom, top), alpha=1)fig = plt.figure()xmin, xmax = xlim = 0, 10ymin, ymax = ylim = 0, 1ax = fig.add_subplot(111, xlim=xlim, ylim=ylim,           autoscale_on=False)X = [[.6, .6], [.7, .7]]ax.imshow(X, interpolation='bicubic', cmap=plt.cm.copper,     extent=(xmin, xmax, ymin, ymax), alpha=1)N = 10x = arange(N) + 0.25y = rand(N)gbar(ax, x, y, width=0.7)ax.set_aspect('auto')plt.show()總結(jié)
以上就是本文關(guān)于Python+matplotlib+numpy繪制精美的條形統(tǒng)計圖的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選