Fall 2026
  • Discord
  • Gradescope
  • Syllabus

On this page

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5
  • Question 6
  • Question 7
  • Question 8
  • Question 9
  • Question 10
  • Question 11
  • Question 12
  • Question 13
  • Question 14
  • Question 15
  • Question 16
  • Question 17
  • Question 18
  • Question 19
  • Question 20
  • Question 21
  • Question 22
  • Question 23
  • Question 24
  • Question 25
  • Question 26
  • Question 27
  • Question 28
  • Question 29
  • Question 30
  • Question 31
  • Question 32

Data Visualization: Practice Questions

To try a snippet, run import matplotlib.pyplot as plt and start with a fresh plot using fig, ax = plt.subplots(). Use plt.show() to display it.

Question 1

The two panels share a title across the top. Which Matplotlib object owns that shared title?

Two panels in one image, each with its own title above bars for Scripps and Pomona.

Answer

The Figure. Each Axes has its own panel title.

Question 2

Every dot is labeled ‘name’. What should the last line say so each dot gets its college’s name?

names = ['Pomona', 'CMC', 'Pitzer']
prices = [18, 19, 40]
earnings = [84, 128, 72]
ax.scatter(prices, earnings)
for name, x, y in zip(names, prices, earnings):
    ax.text(x, y, 'name')
Answer

ax.text(x, y, name)

Question 3

Which two colleges are closest in annual net price?

Annual net price followed by median earnings, both in dollars. Pomona: 18,084 and 84,281. CMC: 19,489 and 127,532. Pitzer: 40,261 and 72,270.

Answer

Pomona and CMC. Their dots are closest together horizontally.

Question 4

The file earnings.png contains the price chart. What should the last line say to save the earnings chart in that file?

schools = ['Pomona', 'Pitzer']
price_fig, price_ax = plt.subplots()
price_ax.bar(schools, [18084, 40261])
earnings_fig, earnings_ax = plt.subplots()
earnings_ax.bar(schools, [84281, 72270])
price_fig.savefig('earnings.png')
Answer

earnings_fig.savefig('earnings.png')

Question 5

Which scatter call would put each quantity on the axis named in its label?

prices = [18, 19, 40]
earnings = [84, 128, 72]
ax.scatter(earnings, prices)
ax.set(xlabel='Net price (thousands of dollars)',
       ylabel='Earnings (thousands of dollars)')
Answer

ax.scatter(prices, earnings)

Question 6

The earnings bars belong in the empty panel on the right. What should the last line say?

schools = ['Pomona', 'Pitzer']
prices = [18084, 40261]
earnings = [84281, 72270]
fig, (left, right) = plt.subplots(1, 2)
left.bar(schools, prices)
left.bar(schools, earnings)
Answer

right.bar(schools, earnings)

Question 7

Both lists start with Pitzer, followed by Pomona and CMC. How would you rewrite the scatter call so each college’s price stays paired with its own earnings?

# Amounts in thousands of dollars
prices = [40, 18, 19]
earnings = [72, 84, 128]
ax.scatter(sorted(prices), earnings)
Answer

ax.scatter(prices, earnings). Sorting just the prices pairs Pomona’s price of 18 with Pitzer’s earnings of 72.

Question 8

ax.bar(names, heights) draws one bar for each name. Which call would compare the colleges’ annual net prices?

schools = ['Pomona', 'CMC', 'Pitzer']
prices = [18084, 19489, 40261]
earnings = [84281, 127532, 72270]
Answer

ax.bar(schools, prices)

Question 9

A counselor has an annual net price for each of 95 colleges. Which type of plot would show how many colleges fall in each 10,000-dollar price interval?

Answer

A histogram. Each bar counts the colleges in one price interval.

Question 10

The dots land at 0, 1, and 2 on the horizontal axis. The first argument to ax.plot(x, y) gives the horizontal positions. What should the last line say to place each dot at its year?

years = [2021, 2022, 2023]
applications = [5632, 5709, 5799]
ax.plot(applications, marker='o')
Answer

ax.plot(years, applications, marker='o')

Question 11

Between which two consecutive years did CMC applications fall the most?

Fall applications, by year from 2019 through 2023, were 6,066, 5,306, 5,632, 5,709, and 5,799.

Answer

Fall 2019 to fall 2020. That’s the steepest downward segment.

Question 12

The route should go from (1, 2) through (4, 2) to (2, 5). What should the plotting call say to put the middle dot in the right place?

ax.plot([1, 2, 2], [2, 2, 5], marker='o')
Answer

ax.plot([1, 4, 2], [2, 2, 5], marker='o')

Question 13

The histogram puts all five colleges in one price range. What should the call say to split that range at 10 thousand dollars?

# Annual net prices in thousands of dollars
prices = [4, 9, 10, 14, 20]
ax.hist(prices, bins=[0, 20])
Answer

ax.hist(prices, bins=[0, 10, 20])

Question 14

One more college reports an annual net price of exactly 20,000 dollars. Each price interval includes its left edge. Which bar gains one college?

Annual net price in 10,000-dollar bins starting at zero. The bar heights from left to right are 9, 36, 25, 15, 10, and 0 colleges.

Answer

The bar from 20,000 up to 30,000 dollars. A value on an interior bin edge goes into the bin that starts there.

Question 15

A histogram groups nine colleges with prices under 10,000 dollars into a single bar. Why can’t you tell how many of the nine cost less than 5,000 dollars?

Answer

Prices on either side of 5,000 dollars count toward the same bar. It could have height nine even if every college in it cost 8,000 dollars.

Question 16

A family wants to compare Pitzer’s net price with the prices at four other named colleges. Would a bar chart by college or a histogram of prices let them find Pitzer’s price by name?

Answer

A bar chart by college. Pitzer has a labeled bar whose height gives its price.

Question 17

An enrollment chart shows 400 students at one campus and 500 at another. The vertical axis starts at 300. How many times as long is the visible 500-student bar as the visible 400-student bar?

Answer

Twice as long. The visible lengths are 200 and 100 students.

Question 18

Which line would replace ax.set_ylim(84000, 90000) to show the full height of both earnings bars while keeping the upper limit at 90,000 dollars?

ax.bar(['Scripps', 'Pomona'], [84025, 84281])
ax.set_ylim(84000, 90000)
Answer

ax.set_ylim(0, 90000)

Question 19

CMC received between 5,306 and 6,066 applications per year. Two line plots show those counts at the same size. Why is a change of 200 applications easier to see on a vertical scale of 5,000 to 6,200 than on one of 0 to 7,000?

Answer

On the narrower scale, 200 applications cover about a sixth of the plot’s height. On the wider scale, they cover about a thirty-fifth.

Question 20

Which campus lost more students between fall 2022 and fall 2023?

Fall enrollment at East, 180 then 120, on a scale from 100 to 200. At West, 400 then 300, on a scale from 0 to 500.

Answer

West. Its enrollment fell by 100 students, while East’s fell by 60.

Question 21

After this loop runs, only the east panel has the requested limits. What should the last line say to give both panels the same vertical scale?

fig, (east, west) = plt.subplots(1, 2)
years = [2022, 2023]
east.plot(years, [100, 150])
west.plot(years, [175, 225])
for panel in (east, west):
    east.set_ylim(0, 250)
Answer

panel.set_ylim(0, 250)

Question 22

Both panels show the same earnings. Why does Pomona’s bar look so much longer than Scripps’s in the left panel?

Scripps, 84,025 dollars, and Pomona, 84,281 dollars. The left panel starts at 84,000 dollars and the right starts at zero.

Answer

The left axis starts at 84,000 dollars. That leaves 281 dollars of Pomona’s bar visible and only 25 dollars of Scripps’s.

Question 23

Every college comes out as a circle. What should the scatter call say so each college uses the marker assigned to its sector?

markers = {'public': 'o', 'private nonprofit': '^'}
rows = [('public', 12, 70), ('private nonprofit', 32, 90),
        ('private nonprofit', 27, 81), ('public', 18, 65)]
for sector, price, earnings in rows:
    ax.scatter(price, earnings, marker=markers['public'])
Answer

ax.scatter(price, earnings, marker=markers[sector])

Question 24

The prices were recorded in dollars. What should the last line say so the axis label matches the prices actually plotted?

net_price = [18084, 19489, 40261]
earnings = [84281, 127532, 72270]
ax.scatter([price / 1000 for price in net_price], earnings)
ax.set_xlabel('Annual net price (dollars)')
Answer

One answer is ax.set_xlabel('Annual net price (thousands of dollars)').

Question 25

A chart is titled ‘Median annual earnings at California colleges.’ The earnings were measured ten years after students started college. How would you revise the title to make the timing clear?

Answer

For example, ‘Median annual earnings ten years after entry at California colleges.’

Question 26

In a black-and-white copy of this figure, which sector does a triangle represent?

The legend shows a circle next to Public and an upward-pointing triangle next to Private nonprofit. Each point marks one college.

Answer

Private nonprofit colleges, according to the legend.

Question 27

The triangles are missing from the legend. What should the second scatter call say to label them ‘Private nonprofit’?

ax.scatter([12, 18], [64, 82], marker='o', label='Public')
ax.scatter([24, 31], [70, 85], marker='^')
ax.legend()
Answer

ax.scatter([24, 31], [70, 85], marker='^', label='Private nonprofit')

Question 28

Three colleges appear as partly transparent blue circles at (20, 70), (20, 70), and (30, 80). Which position will look darkest?

Answer

(20, 70). Two circles overlap there.

Question 29

These lines will be printed in black and white. The available line styles include 'solid', 'dashed', and 'dotted'. How would you rewrite the offers call so readers can tell the two lines apart?

years = [2022, 2023, 2024]
applications = [500, 540, 575]
offers = [240, 270, 290]
ax.plot(years, applications, color='black', linestyle='solid', label='Applications')
ax.plot(years, offers, color='black', linestyle='solid', label='Offers')
ax.legend()
Answer

One answer is ax.plot(years, offers, color='black', linestyle='dashed', label='Offers'). A dotted line also works.

Question 30

The earnings data include former federal aid recipients who are working and out of school ten years after entry. Ana, Ben, and Cam all started ten years ago and now work. Cam was the only one who didn’t receive federal aid. Ana is the only one still in school. Whose earnings are included?

Answer

Ben’s. Ana is still enrolled, and Cam didn’t receive federal aid.

Question 31

Harvey Mudd and Pitzer have similar net prices, and Harvey Mudd has higher median earnings. Why doesn’t that gap tell a Pitzer student what they would earn after transferring to Harvey Mudd?

Harvey Mudd is near 40,000 dollars in net price and 164,000 in median earnings. Pitzer is near 40,000 and 72,000, respectively.

Answer

The dots describe two different groups of students. For example, differences in their majors could account for part of the earnings gap.

Question 32

Each list contains annual net prices in thousands of dollars. What should the last line say so the two histograms use the same price intervals?

a = [4, 8, 12]
b = [7, 19, 22]
edges = [0, 10, 20, 30]
fig, (left, right) = plt.subplots(1, 2)
left.hist(a, bins=edges)
right.hist(b, bins=[0, 15, 30])
Answer

right.hist(b, bins=edges)