Topics / 🗄️ SQL, pandas & Data Analysis / 📊 Level 19: Charts & Time Series

Python exercise · about 5 minutes · free

Bar Chart: Compare Categories

Four channels, four default rates. A bar chart makes the outlier jump out.

With matplotlib: fig, ax = plt.subplots(), then ax.bar(labels, values). Always add a title and axis labels. Click Run to see your chart below the editor.

Bar chart: branch 7.2%, online 8.2%, agent 11.9%, partner 7.9%. what you're building: the agent bar stands out7.2%branch8.2%online11.9%agent7.9%partnerwhat you're building: the agent bar stands out
Your quest: Draw a bar chart of rates by channels, titled Default rate by channel, with a y-axis label containing %.
Starter code
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt

channels = ["branch", "online", "agent", "partner"]
rates = [7.2, 8.2, 11.9, 7.9]
fig, ax = plt.subplots()
# draw the bars, then set the title and y label

Try it in your browser → Free. Sign in with Google to run it. Your code runs on your device.

In this level you'll learn:
More in Level 19: Charts & Time Series

Share on LinkedIn