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

完整代碼如下:
import matplotlib.pyplot as plt
from numpy import arange
from numpy.random import rand
def 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, 10
ymin, ymax = ylim = 0, 1
ax = 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 = 10
x = arange(N) + 0.25
y = rand(N)
gbar(ax, x, y, width=0.7)
ax.set_aspect('auto')
plt.show()
總結(jié)
以上就是本文關(guān)于Python+matplotlib+numpy繪制精美的條形統(tǒng)計(jì)圖的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!
相關(guān)文章
Pandas修改DataFrame列名的兩種方法實(shí)例
這篇文章主要給大家介紹了關(guān)于Pandas修改DataFrame列名的兩種方法,文中通過實(shí)例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Pandas具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2022-03-03
pymongo如何通過oplog獲取數(shù)據(jù)(mongodb)
使用MongoDB的oplog(操作日志)進(jìn)行數(shù)據(jù)同步是高級的用法,主要用于復(fù)制和故障恢復(fù),這篇文章主要介紹了pymongo通過oplog獲取數(shù)據(jù)(mongodb),需要的朋友可以參考下2023-09-09
python tkinter的消息框模塊(messagebox,simpledialog)
這篇文章主要介紹了python tkinter的消息框模塊,幫助大家更好的理解和使用python,感興趣的朋友可以了解下2020-11-11
pyecharts如何實(shí)現(xiàn)顯示數(shù)據(jù)為百分比的柱狀圖
這篇文章主要介紹了pyecharts如何實(shí)現(xiàn)顯示數(shù)據(jù)為百分比的柱狀圖,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-11-11
Python的Matplotlib庫圖像復(fù)現(xiàn)學(xué)習(xí)
這篇文章主要給大家介紹了關(guān)于如何利用Matplotlib庫圖像復(fù)現(xiàn),matplotlib模塊提供了很高級和非常友好的使用方式,使用起來也是非常方便的,需要的朋友可以參考下2021-08-08

