Skip to main contentSkip to solution

Which attribute of plot() function is used to set the style of line in a line chart?

Solution

✅ Correct Option: 4

The linestyle parameter of matplotlib's plot() function sets the style of the line. Values include '-' (solid), '--' (dashed), ':' (dotted) and '-.' (dash-dot). It can be shortened to ls.

Example: plt.plot(x, y, linestyle='--')


Options 1, 2 and 3: these are not valid plot() parameters, and passing them raises an error.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question