文章詳情頁(yè)
python matplotlib繪圖怎么讓每個(gè)柱面顏色不一樣?
瀏覽:134日期:2022-07-18 15:54:19
問(wèn)題描述
def huitu_host(nodes,total): x = np.arange(len(nodes)) plt.figure(figsize=(9,5)) plt.xticks(x,nodes) plt.bar(x,total,width = 0.5,facecolor = ’yellowgreen’,edgecolor = ’white’) for x,y in zip(x,total):plt.text(x,y,’%.f’ % y,ha='center', va='bottom') plt.show() return
問(wèn)題解答
回答1:color和edgecolor這些都能傳array-like的參數(shù)在array里分別指定顏色就好了例子:
x=np.arange(10)y=np.arange(10)plt.bar(x,y,color=[’red’,’green’])
相關(guān)文章:
1. golang - 用IDE看docker源碼時(shí)的小問(wèn)題2. nignx - docker內(nèi)nginx 80端口被占用3. javascript - vue使用videojs+videojs-contrib-hls報(bào)錯(cuò)4. io - java 文件操作,如何向指定的位置插入內(nèi)容 (不是替換內(nèi)容) ?5. javascript - JS 里面的 delete object.key 到底刪除了什么?6. javascript - webpack --hot 熱重載無(wú)效的問(wèn)題7. dockerfile - [docker build image失敗- npm install]8. Python 爬蟲(chóng) 遇到的問(wèn)題(手淘問(wèn)大家)9. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””10. mysql如何配置遠(yuǎn)程php外網(wǎng)鏈接數(shù)據(jù)庫(kù)
排行榜

熱門標(biāo)簽