Recall & Review
beginner
What is the purpose of highlighting date ranges in a plot?
Highlighting date ranges helps to visually emphasize specific periods in time, making it easier to spot trends, events, or anomalies within those intervals.
Click to reveal answer
beginner
Which matplotlib function is commonly used to highlight a date range on a plot?
The
ax.axvspan(start_date, end_date, color=color, alpha=alpha) function is used to highlight vertical spans (date ranges) on a plot.Click to reveal answer
beginner
How do you specify the transparency of a highlighted date range in matplotlib?
Use the
alpha parameter in axvspan to set transparency. Values range from 0 (fully transparent) to 1 (fully opaque).Click to reveal answer
intermediate
Why is it important to convert dates to matplotlib date format before highlighting?
Matplotlib needs dates in its internal numeric format to correctly position highlights on the x-axis. Using
matplotlib.dates.date2num() converts datetime objects to this format.Click to reveal answer
intermediate
What is a simple way to add multiple highlighted date ranges on the same plot?
Call
ax.axvspan() multiple times with different start and end dates and colors to highlight several date ranges on the same plot.Click to reveal answer
Which matplotlib function highlights a vertical date range on a plot?
✗ Incorrect
ax.axvspan() highlights vertical spans, perfect for date ranges on the x-axis.
What does the
alpha parameter control in axvspan?✗ Incorrect
alpha sets transparency from 0 (invisible) to 1 (solid).
Before highlighting dates, why convert datetime objects using
date2num()?✗ Incorrect
Matplotlib needs numeric values to position highlights correctly on the axis.
If you want to highlight two separate date ranges, what should you do?
✗ Incorrect
Multiple calls to axvspan allow highlighting multiple date ranges.
What color parameter can you use in
axvspan to highlight a date range?✗ Incorrect
The color parameter sets the fill color of the highlighted area.
Explain how to highlight a specific date range on a matplotlib plot step-by-step.
Think about converting dates and using axvspan with parameters.
You got /4 concepts.
Describe why highlighting date ranges can be useful in data visualization.
Consider how visual emphasis helps understanding.
You got /4 concepts.