Recall & Review
beginner
What is the main purpose of a legend in a plot?
A legend explains what different colors, shapes, or lines in a plot represent, helping the reader understand the data categories or groups.
Click to reveal answer
beginner
How does a colorbar help in reading a heatmap or scatter plot?
A colorbar shows the mapping between colors and data values, so the reader can tell what value each color represents in the plot.
Click to reveal answer
beginner
Why is it important to include legends and colorbars in data visualizations?
They guide the reader by providing clear explanations of visual elements, making the plot easier to understand and interpret correctly.
Click to reveal answer
beginner
What could happen if a plot lacks a legend or colorbar?
The reader might get confused or misinterpret the data because they don’t know what the colors or symbols mean.
Click to reveal answer
beginner
In matplotlib, which function is commonly used to add a legend to a plot?
The function plt.legend() is used to add a legend that explains plot elements like lines or markers.
Click to reveal answer
What does a legend in a plot usually explain?
✗ Incorrect
A legend explains what different visual elements like colors or shapes represent in the data.
Which matplotlib function adds a colorbar to a plot?
✗ Incorrect
plt.colorbar() adds a colorbar that shows the scale of colors used in the plot.
Why is a colorbar useful in a heatmap?
✗ Incorrect
A colorbar helps the reader understand what data values correspond to each color in the heatmap.
What might happen if a plot has no legend or colorbar?
✗ Incorrect
Without legends or colorbars, readers may not understand what the visual elements mean.
Which of these is NOT a reason to use legends and colorbars?
✗ Incorrect
Legends and colorbars are for explanation and clarity, not just decoration.
Explain why legends and colorbars are important when reading a plot.
Think about how you know what each color or symbol means in a graph.
You got /4 concepts.
Describe how you would add a legend and a colorbar in a matplotlib plot.
Remember the matplotlib functions for legends and colorbars.
You got /4 concepts.