【发布时间】:2021-03-08 11:38:37
【问题描述】:
我正在尝试切换条形图的颜色,以便它们始终保持一致。在下面的图中,我想让 JP_Sales 在两个图表中都是橙色,而 NA_Sales 在两个图表中都是蓝色。
第一个图表的代码是:
Genre_sales.plot(kind= 'bar', rot=75, figsize = (15,10))
plt.suptitle('Sales by Region and Genre')
plt.ylabel('Total Units (Millions)')
第二张图表的代码是:
PercentSales.plot(kind = 'bar', rot = 80, figsize=(15,10))
plt.suptitle('Percentage by Genre Sales by Region')
plt.xlabel('Genre')
plt.ylabel('Percent')
【问题讨论】:
-
您需要 [stackoverflow.com/questions/25689558/… 条形图,按列指定条形颜色)中的第二个答案,因此使用字典将名称映射到它们的颜色。
标签: python pandas matplotlib