Plot a horizontal line on a given plot

Use axhline (a horizontal axis line). For example, this plots a horizontal line at y = 0.5:

import matplotlib.pyplot as plt
plt.axhline(y=0.5, color="r", linestyle="-")
plt.show()

sample figure

Leave a Comment