Which of the following properties of matplotlib is used to change the type of lines, such as "solid", "dotted", "dashed" etc.?
Which of the following properties of matplotlib is used to change the type of lines, such as "solid", "dotted", "dashed" etc.?
Solution
✅ Correct Option: 2
The linestyle property (short form ls) sets the pattern of a line in matplotlib, such as "solid", "dotted", "dashed" or "dashdot". Example: plt.plot(x, y, linestyle="dashed").
Shorthand symbols also work: "-" solid, "--" dashed, ":" dotted, "-." dash-dot.
Option 1: linewidth (or lw) changes the thickness of the line, not its pattern.
Option 3: linetype is not a matplotlib property. It is a common mix-up with linestyle.
Related questions:
2026: 20 May Shift 1
2026: 18 May Shift 2
2025: 30 May Shift 2
2026: 29 May Shift 1
2026: 21 May Shift 1
2026: 24 May Shift 1