Python Bar Chart
plt.barPractice

Compare categories with bars

Press Run to grow each bar to its value — the same idea as plt.bar(cats, vals).

Picture this: one bar per group

Height encodes the number. Categories sit on the x-axis.

catsA B C
→
vals10 7 12
→
plt.bardraw
→
barscompare

In easy words

Bars are for named groups, not ordered time. Taller means more.

Where this is used

Votes per candidate, sales per region, counts per error type.

Run algorithm

Each step highlights the matching Python line. Program output appears only when a line that prints actually runs.

Ready
A
B
C
1import matplotlib.pyplot as plt
2cats = ["A", "B", "C"]
3vals = [10, 7, 12]
4plt.bar(cats, vals)
5plt.show()
Output:

Example Program

1import matplotlib.pyplot as plt
2cats = ["A", "B", "C"]
3vals = [10, 7, 12]
4plt.bar(cats, vals)
5plt.show()