Recall & Review
beginner
What is a named color in matplotlib?
A named color is a color identified by a simple name like 'red', 'blue', or 'green' that matplotlib recognizes and can use directly in plots.
Click to reveal answer
beginner
What does a hex code represent in color specification?
A hex code is a 6-digit code starting with '#' that represents a color by specifying the amounts of red, green, and blue in hexadecimal format, like '#FF0000' for red.
Click to reveal answer
beginner
How do you use a named color in a matplotlib plot?
You can use a named color by passing its name as a string to color-related parameters, for example: plt.plot(x, y, color='blue').
Click to reveal answer
beginner
Give an example of a hex code for the color green.
The hex code for green is '#00FF00'. It means no red, full green, and no blue.
Click to reveal answer
intermediate
Why might you choose a hex code over a named color in matplotlib?
Hex codes allow you to specify exact shades and more colors than the limited named colors, giving you more control over the plot's appearance.
Click to reveal answer
Which of these is a valid named color in matplotlib?
✗ Incorrect
Only 'skyblue' is a valid named color. Hex codes must have valid hex digits, and 'bluish' and 'reddish' are not recognized named colors.
What does the hex code '#0000FF' represent?
✗ Incorrect
The hex code '#0000FF' means no red, no green, and full blue, so it represents blue.
How would you specify the color red using a named color in matplotlib?
✗ Incorrect
The named color for red is simply 'red'. Hex codes like '#FF0000' also represent red but are not named colors.
Which is true about hex codes in matplotlib?
✗ Incorrect
Hex codes start with '#' and use hexadecimal digits (0-9, A-F) to represent colors.
Why use named colors instead of hex codes?
✗ Incorrect
Named colors are easier to remember and type, making them convenient for quick plotting.
Explain the difference between named colors and hex codes in matplotlib.
Think about how you pick colors for clothes versus mixing paint exactly.
You got /4 concepts.
How would you use a hex code to set a plot line color in matplotlib? Give an example.
Remember the syntax plt.plot(x, y, color='...')
You got /3 concepts.