I am trying to create 3 horizontal bar charts in 3 separate subplots in matplotlib. However for some reason, all the graphs are being pasted onto only on one subplot rather than one in each of their own area.
cols = ["Education_Level", "Marital_Status", "Income_Category"]
fig, axs = plt.subplots(1, len(cols), figsize=(15, 6), tight_layout=True)
for idx, col_name in enumerate(cols):
data = df[col_name].value_counts()
axs[idx] = plt.barh(
data.index,
data.values
)
I have tried to manually separate it out. For example using axs(1) in order to forcefully have the graph showing in the middle subplot still doesn't work and still applies it to the last one.