Expenses, expenses, expenses...

Report a typo

Suppose you want to create a stacked bar chart showing the categories with your expenses. Type in the missing line of code for the third bar category, so the resulting bar chart is as follows:

import matplotlib.pyplot as plt
import numpy as np

months = ['January', 'February', 'March']
transport = np.array([760, 575, 955])
food = np.array([597, 710, 675])
healthcare = np.array([395, 210, 450])

plt.bar(months, transport, width=0.9, label='Transport')
plt.bar(months, food, width=0.9, label='Food', bottom=transport)
# YOUR CODE HERE #

plt.xlabel("Period", fontsize=12)
plt.ylabel("Amount ($) ", fontsize=12)
plt.legend()
plt.title("My monthly expenses", fontsize=14)

plt.show()

Create a stacked bar chart with three expenses categories: food, transport, healthcare

Enter a short text
___

Create a free account to access the full topic