Recall & Review
beginner
How do you change the color of a line in matplotlib?
You can change the line color by using the
color parameter in the plot() function. For example, plt.plot(x, y, color='red') draws a red line.Click to reveal answer
beginner
What parameter controls the thickness of a line in matplotlib?
The
linewidth (or lw) parameter controls the thickness of the line. For example, plt.plot(x, y, linewidth=3) makes the line thicker.Click to reveal answer
beginner
Can you use color names and hex codes to set line colors in matplotlib?
Yes! You can use named colors like 'blue', 'green', or hex color codes like '#FF5733' to set line colors.
Click to reveal answer
beginner
What is the default line width in matplotlib if you don't specify it?
The default line width is 1.5, which is a thin line.
Click to reveal answer
intermediate
How do you set multiple lines with different colors and widths in one plot?
Call
plt.plot() multiple times with different color and linewidth values for each line. For example:<br>plt.plot(x, y1, color='red', linewidth=2)<br>plt.plot(x, y2, color='blue', linewidth=4)Click to reveal answer
Which parameter changes the line thickness in matplotlib?
✗ Incorrect
The
linewidth parameter controls how thick the line appears.How would you make a green line in matplotlib?
✗ Incorrect
The
color parameter sets the line color.What is the default line width if you don't specify it?
✗ Incorrect
Matplotlib uses a default line width of 1.5.
Which of these is a valid way to specify a color in matplotlib?
✗ Incorrect
Hex color codes like '#00FF00' are valid color specifications.
How do you plot two lines with different colors and widths?
✗ Incorrect
You plot each line separately with its own color and linewidth.
Explain how to change the color and thickness of a line in matplotlib.
Think about the parameters inside plt.plot()
You got /3 concepts.
Describe how to plot multiple lines with different colors and widths on the same graph.
Each line needs its own plot call with settings
You got /3 concepts.