Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.
The default linestyle while plotting data is solid linestyle in matplotlib. We can change this linestyle by using linestyle or ls argument of plot() method.
Following are the linestyles available in matplotlib:
Using linestyle Argument:
Using ls Argument:
- ‘ ‘
- Import module.
- Create data.
- Normally plot the data by setting linestyle or ls argument of plot() method.
- Display plot.
Below are various programs to depict various line styles available in matplotlib module:
Example 1: Program to depict dotted line style in a plot.
Example 2: Program to depict dash dot line style in a plot.
Example 3: Program to depict dashed line style in a plot using ls argument.
Example 4: Program to depict solid line style in a plot using ls argument.
All the above types of line styles can be visualized using the linestyle or ls argument. The none or ‘ ‘ when visualized will generate a blank plot.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.