You can add a horizontal line in Matplotlib with the following code. If you want to learn Python then I will highly recommend you to read This Book.
![How to add a horizontal line in Matplotlib](https://aihints.com/wp-content/uploads/2022/03/How-to-add-a-horizontal-line-in-Matplotlib.png)
Draw a horizontal line starting from 6 and ending at 14.
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.hlines(y=3, xmin=6, xmax=14, linewidth=3, color='b') plt.show()
![](https://aihints.com/wp-content/uploads/2022/03/figure-17.png)
Different Horizontal Lines
import matplotlib.pyplot as plt plt.title("Horizontal Lines") plt.axhline(y=0.2, color='green', linestyle='-') plt.axhline(y=0.6, xmin=0.4, xmax=0.8, color='blue', linewidth=2) plt.axhline(y=2, xmin=0.2, xmax=0.9,color='red', linestyle='-.', linewidth = 3) plt.show()
![](https://aihints.com/wp-content/uploads/2022/03/figure-16.png)
People are also reading:
What is Computer Vision? Examples, Applications, Techniques
Top 10 Computer Vision Books with Python
Books for Machine Learning (ML)