文章詳情頁
python matplotlib繪圖怎么讓每個柱面顏色不一樣?
瀏覽:220日期:2022-07-18 15:54:19
問題描述
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
問題解答
回答1:color和edgecolor這些都能傳array-like的參數在array里分別指定顏色就好了例子:
x=np.arange(10)y=np.arange(10)plt.bar(x,y,color=[’red’,’green’])

相關文章:
1. vim - docker中新的ubuntu12.04鏡像,運行vi提示,找不到命名.2. mac連接阿里云docker集群,已經卡了2天了,求問?3. docker網絡端口映射,沒有方便點的操作方法么?4. 為什么我ping不通我的docker容器呢???5. angular.js - angular內容過長展開收起效果6. phpstudy8.1沒集成mysql-front7. html5和Flash對抗是什么情況?8. 我何時應該在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)9. 利用IPMI遠程安裝centos報錯!10. 前端 - @media query 使用出現的問題?
排行榜

網公網安備