Function to produce stacked bar chart using matplotlib in python