
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to draw more type of lines in Matplotlib?
To draw more type of lines in Matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create x and y data points using numpy.
- Plot x and y data points using plot() method, with an array of dashes.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 100) y = np.sin(x) plt.plot(x, y, dashes=[1, 1, 2, 1, 3], linewidth=7, color='red') plt.show()
Output
- Related Articles
- How to draw axis lines inside a plot in Matplotlib?
- How to draw grid lines behind Matplotlib bar graph?
- How to draw parallel lines?
- How to hide lines in Matplotlib?
- How to plot overlapping lines in Matplotlib?
- Draw axis lines or the origin for Matplotlib contour plot.
- How to remove lines in a Matplotlib plot?
- How to draw lines using HTML5 Canvas?
- How to name different lines in the same plot of Matplotlib?
- How to make markers on lines smaller in Matplotlib?
- How to draw node colormap in NetworkX/Matplotlib?
- How to draw a filled arc in Matplotlib?
- How to draw a line outside of an axis in Matplotlib?
- How to annotate the end of lines using Python and Matplotlib?
- How to draw axis in the middle of a figure in Matplotlib?

Advertisements