axhline, axvline を使ってx,y軸に平行な線を描くことができる。
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.axhline.html
例
import math
import numpy as np
from matplotlib import pyplot as plt
x = np.linspace(-3, 3, num=100, endpoint=True)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x,y,'red',label='sin(x)',color='green')
ax.axhline(y=0.5,color='blue',linestyle='-.')
ax.axvline(x=0.5*math.pi,color='cyan',linestyle='--')
plt.show()
結果
![](https://hanjouchan.org/wp-content/uploads/2021/07/screenshot-2021-06-11-at-16.08.20-1024x893.png)