罫線を出力するには、pyplot.grid を使う。
例
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2, 100)
plt.plot(x, x, label='linear')
plt.plot(x, x*x, label='quad')
plt.xlabel('x axis')
plt.ylabel('y axis')
plt.grid(color='b', linestyle=':', linewidth=0.3)
plt.title("title", color='rebeccapurple')
plt.legend()
plt.show()
結果

参考
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.grid.html