matplotlib plot line style

The matplotlib library in Python provides several line styles that can be used to customize the appearance of plots. These line styles can be specified using the linestyle parameter when plotting lines.

Here are some commonly used line styles in matplotlib:

  • Solid line: `'-'
  • Dashed line: '--'
  • Dotted line: ':'
  • Dash-dot line: '-.'
  • No line: ''

To specify a line style when plotting a line using matplotlib, you can use the linestyle parameter. For example, the following code snippet plots a dashed line:

import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [1, 4, 9, 16]

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

You can replace '--' with any of the other line style options mentioned above to customize the appearance of the line in your plot.