Checkpoint: Data Visualization

A checkpoint is a chance to consolidate, where you review the data-visualization skills from the recent lessons and prove them by building one complete, polished, annotated figure of your own.

Learn Checkpoint: Data Visualization in our free Matplotlib course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a…

Part of the free Matplotlib course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.

You'll recap vector fields, spines, advanced legends, inset and broken axes, patches, events, multiple figures, tables, log scales, the extra plot types, and donuts — then put them to work in a multi-step build challenge and a short quiz.

You have added a deep set of tools since the last checkpoint. Here is the quick map of what each one is for, so you can pick the right technique when you build the challenge below.

Before the big build, warm up by combining a clean spine treatment with a shaded region and an annotation — three small skills working together on one line chart.

What you'll see: a navy curve on an open L-shaped frame, a gold band marking the region of interest, and an arrow labeling the local peak inside it — three techniques in one tidy figure.

Build a two-panel figure for a fictional product launch. Left panel: a semilog line of daily downloads (which grow exponentially) with the top and right spines hidden and the launch day annotated. Right panel: a donut of traffic sources with percentage labels and a legend. Give the whole figure a title.

Start from the scaffold below and fill in each # TODO . Build one piece at a time and run after each. When you are done, expand the solution to compare.

Answer each question in your head, then expand to check yourself.

ax.streamplot(X, Y, U, V) . It integrates the field into smooth curves, whereas ax.quiver draws a discrete arrow at each grid point.

Set their visibility to False: ax.spines['top'].set_visible(False) and ax.spines['right'].set_visible(False) .

loc together with bbox_to_anchor — for example ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) parks it to the right.

symlog : ax.set_yscale('symlog', linthresh=...) is linear near zero and logarithmic beyond it, so it handles negatives and the zero crossing a plain log cannot.

Pass wedgeprops=dict(width=0.4) to ax.pie() . The width is the ring thickness, so the rest of the center becomes the hole.

ax.broken_barh(xranges, yrange) : each task is one row, and a single call can place several (start, duration) segments with gaps between them.

Checkpoint cleared — you can compose a polished figure!

You recapped the whole advanced toolkit, combined spines, patches, annotations, log scales, and donuts into one dashboard, and tested yourself with the checkpoint quiz.

🚀 Up next: Capstone Project — design a complete multi-panel visualization from scratch on a dataset of your choice.

Practice quiz

Which Matplotlib function traces continuous flow lines through a vector field?

  • ax.quiver(X, Y, U, V)
  • ax.streamplot(X, Y, U, V)
  • ax.plot(X, Y)
  • ax.contour(X, Y, Z)

Answer: ax.streamplot(X, Y, U, V). streamplot integrates the field into smooth, continuous curves, whereas quiver draws a discrete arrow at each grid point.

How do you hide the top and right borders of an axes for a clean, minimalist frame?

  • ax.set_frame_on(False)
  • top

Answer: top. Setting individual spines' visibility to False removes just those borders, leaving an open L-shaped frame; axis('off') would hide everything.

Which pair of arguments parks a legend outside the axes, for example to the right?

  • loc together with bbox_to_anchor
  • ncol together with frameon
  • title together with fontsize
  • shadow together with fancybox

Answer: loc together with bbox_to_anchor. ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) anchors the legend just outside the right edge of the axes.

Your data crosses zero but still spans huge magnitudes. Which y-scale fits?

  • set_yscale('log')
  • set_yscale('linear')
  • set_yscale('symlog')
  • set_yscale('logit')

Answer: set_yscale('symlog'). symlog is linear near zero and logarithmic beyond it, so it handles negative values and the zero crossing that a plain log scale cannot.

How do you turn a normal pie chart into a donut?

  • Pass hole=0.4 to ax.pie()
  • Pass wedgeprops=dict(width=0.4) to ax.pie()
  • Call ax.donut() instead of ax.pie()
  • Set ax.set_aspect('donut')

Answer: Pass wedgeprops=dict(width=0.4) to ax.pie(). wedgeprops=dict(width=0.4) draws each slice as a ring of that thickness, leaving the center as a hole.

Which plot type best charts a Gantt-style schedule with gaps between segments?

  • ax.eventplot
  • ax.broken_barh
  • ax.stairs
  • ax.fill_between

Answer: ax.broken_barh. broken_barh(xranges, yrange) places several (start, duration) bars on one row, ideal for Gantt timelines with gaps.

Which function adds a magnified zoom-in panel inside an existing axes?

  • inset_axes
  • twinx
  • secondary_xaxis
  • add_subplot

Answer: inset_axes. inset_axes places a small child axes within the parent so you can show a zoomed view of part of the data.

How do you make a figure react to mouse clicks or key presses?

  • fig.canvas.mpl_connect('button_press_event', handler)
  • fig.add_listener('click', handler)
  • ax.onclick(handler)
  • plt.interactive(True)

Answer: fig.canvas.mpl_connect('button_press_event', handler). mpl_connect binds an event name (like 'button_press_event' or 'key_press_event') to a callback that receives the event.

To shade or annotate a rectangular region of interest under a curve, which tool do you reach for?

  • ax.add_patch with a Rectangle
  • ax.set_facecolor
  • ax.imshow
  • ax.bar

Answer: ax.add_patch with a Rectangle. Adding a patches.Rectangle via ax.add_patch lets you draw a semi-transparent band over the region you want to highlight.

In the build challenge, why call ax_pie.set_aspect("equal") on the donut axes?

  • It scales the wedges by their values
  • It keeps the donut circular instead of squashed into an ellipse
  • It adds percentage labels automatically
  • It is required before calling ax.legend

Answer: It keeps the donut circular instead of squashed into an ellipse. set_aspect('equal') forces equal x and y scaling so the pie/donut renders as a true circle rather than an oval.