I need to plot two sets of barplots side by side with their values on two separate y-axis.
In the example code below, my population bar is in different scale with income. It's not working with just one axis.
Here is what I need:
- I need plot three bars for income of each region. Also I need three population bars right next to each of the income bar.
- Because they are in different scale, I will need dual y axis.
- Values on top of each bar.
import matplotlib.pyplot as plt
import seaborn as sns
data = pd.DataFrame({'region': ['A', 'B', 'C'],
'population': [1000, 2000, 30000],
'income': [40, 50, 60]})
data = pd.melt(data, id_vars=['region'], var_name='metric', value_name='value')
sns.barplot(data=data, x='region', y= 'value', hue='metric')