Skip to main contentSkip to solution

To customize the plot and create the dashed line pattern, which of the following parameter is used?

Solution

✅ Correct Option: 1

In Matplotlib, the linestyle parameter (short form ls) sets the line pattern of a plot, for example plt.plot(x, y, linestyle='dashed') or linestyle='--'.


Options 2, 3 and 4: linetype, line_type and line_style are not valid Matplotlib keyword arguments, and using them raises an error. R's lty and linetype (in ggplot2) are the likely source of the confusion.

Other common values are 'solid' ('-'), 'dotted' (':') and 'dashdot' ('-.').

Keyboard Shortcuts

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