Pandas 将条形图颜色设置为匹配的列数据

Pandas 将条形图颜色设置为匹配的列数据,pandas,plot,Pandas,Plot,我有一个图表,其中的值是颜色的数量(4个红色,5个蓝色,1个白色)等等。 当我尝试我的代码时,红色是绿色的,白色是黑色的,我如何给这些条上色以匹配数据 def this_family(): data = pd.read_sql('SELECT * FROM toys WHERE Date >= ? ', conn, params=(this_month,)) my_colours = [item for item in data['Family'].drop_dupl

我有一个图表,其中的值是颜色的数量(4个红色,5个蓝色,1个白色)等等。 当我尝试我的代码时,红色是绿色的,白色是黑色的,我如何给这些条上色以匹配数据

def this_family():
    data = pd.read_sql('SELECT * FROM toys WHERE Date  >= ?   ', conn, params=(this_month,))
    my_colours = [item for item in data['Family'].drop_duplicates()] # get a list of all the colours effected
    c = dict(zip(my_colours, my_colours))
    data.groupby(['Name','Family']).size().unstack().plot(kind='bar', stacked=True, edgecolor='black',figsize=(14,6),)
    plt.savefig("mysite/Static/this_family.png",bbox_inches = "tight"
其中“族”列包含一种颜色。

通过对初始数据库查询进行排序,解决了这一问题