I can easily create the bar plot in pandas as below:
import pandas as pd
revenue = [100, 110, 105, 120, 95]
profit = [35, 50, 45, 65, 30]
quarter = ['Q2/22', 'Q1/22', 'Q4/21', 'Q3/21', 'Q2/21']
df = pd.DataFrame({'Revenue': revenue, 'Profit': profit}, index=quarter)
df.plot(kind='bar')
when I try to plot the same df in seaborn it gives me different graph:
import seaborn as sns
sns.barplot(data=df)
i tried melting the df but the results are the same
>Solution :
Using melt and then barplot with hue:
temp = (df.melt(ignore_index=False, var_name='category')
.reset_index().rename(columns={'index': 'quarter'}))
sns.barplot(x='quarter', y='value', hue='category', data=temp)
Output:


