![](/img/trans.png)
[英]how to plot horizontal bar plot in loop to change the color on the bar based on the value in another column
[英]Pandas bar graph plot with different color for each column based on value
經過艱苦的反復試驗,我找到了一個解決方案。 思路是把plot條形圖正常,然后根據一些條件修改。 這是一個示例代碼:
....
ax = df.plot(x='column_name', ... , color=colors)
for bar in ax.patches:
if bar.get_height() > some_value:
bar.set_color('red')
....
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.