An AI draft with mean bars under a title about totals

Code review · Medium · §4.3 Arranging charts and saving results

You asked an AI to draw this week's total sales for each menu item at the student cafeteria and got this code. When you run it, it stops with an error.

After fixing the error, check that the bars show each menu item's 5-day total, as the title says. Keep the title and axis labels as they are, and fix the bars. You can fix it by changing two lines or fewer.

Target figure for An AI draft with mean bars under a title about totals
Target figure

Code to fix

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

days = ["Mon", "Tue", "Wed", "Thu", "Fri"]
bibimbap = [40, 52, 46, 50, 38]
curry = [22, 28, 25, 25, 20]
ramen = [30, 26, 34, 30, 28]
daily = pd.DataFrame({"day": days, "Bibimbap": bibimbap, "Curry": curry, "Ramen": ramen})
meals = daily.melt(id_vars="day", var_name="menu", value_name="sold")

fig, ax = plt.subplots()
sns.barplot(data=meals, x="Menu", y="sold", errorbar=None, ax=ax)
ax.set(title="Total sold this week", xlabel="Menu", ylabel="Total sold")
plt.show()

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.