I am using a for loop to make some bar charts but they are overriding each other as it's possible to see in the screenshot below
This is the code that I am using to draw the plot charts.
# Exploration: Categorical Vs Categorical -- bar charts
fig, PlotCanvas=plt.subplots(nrows=len(categFeatures),
ncols=1, figsize=(15,10))
# Creating Grouped bar plots for each categorical predictor against the Target Variable "lifequality"
for CategoricalCol,i in zip(categFeatures,range(len(categFeatures))):
CrossTabResult=pd.crosstab(index=df[CategoricalCol],
columns=df['lifequality'])
CrossTabResult.plot.bar(color=['red','green'], ax=PlotCanvas[i])
plt.show()
How can i fix this? After using
plt.tight_layout()