【问题标题】:How can I change a single bar in a bar plot to a different colour?如何将条形图中的单个条形更改为不同的颜色?
【发布时间】:2021-04-23 16:02:43
【问题描述】:

我有一个如下所示的数据框

ACQUISITION_CHANNEL RIDER_ID
Organic 2735
Referral 1216
Digital 751
Offline 296
Unknown 108
Job Platforms 67

我正在制作如下条形图:

channel_rider_count.plot(kind='bar', 
                         legend=None)

plt.title('Count of Riders by Acquisition Channel')
plt.xlabel('Acquisition Channel')
plt.ylabel('Count')

如何更改“推荐”栏的颜色,但保持其他颜色不变?

【问题讨论】:

标签: pandas matplotlib plot jupyter


【解决方案1】:
colors = ['b','r','b','b','b','b','b']

channel_rider_count.plot(kind='bar', 
                         legend=None, 
                         color=colors)

plt.title('Count of Riders by Acquisition Channel')
plt.xlabel('Acquisition Channel')
plt.ylabel('Count')

【讨论】:

    猜你喜欢
    • 2013-12-11
    • 2011-08-03
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 2021-09-24
    • 2016-07-26
    • 2012-10-18
    相关资源
    最近更新 更多