I am trying to plot group of bar charts. I was able to give different colors within each group but how to give different colors to different groups?
MWE
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.DataFrame({0: [10,20,80],
1: [20,40,60]},index=['a','b','c'])
df
# another test dataframe
df = pd.DataFrame({0: [10,20,80,10],
1: [20,40,60,70],
2: [20,40,60,70],
},
index=['a','b','c','d'])
pal = 'magma'
color=sns.color_palette(pal,len(df)) # list of rgb
fig, ax = plt.subplots()
df.plot.bar(ax=ax,color=color)
Output
Required
Here the variable color
has three values, I want to use these three colors for three groups. For example group a
now has two colors, I want it to have only one color.