- 水平线
plt.axhline(y=0,xmin=value,xmax=value,color='k',linestyle='dashed')
解释:
xmin:水平线x轴的最小值
xmax:水平线x轴的最大值
color:水平线的颜色,k是指黑色
linestyle:dashed表示虚线,也可类似plt.plot(x_values,y_values,’- -’)
示例:
plt.axhline(y=2,linestyle='dashed')
结果:
- 垂直线
plt.axvline(x=0,ymin=value,ymax=value,color='k',linestyle='dashed')
示例:
plt.axvline(x=0.5,ymin=0,ymax=1,linestyle="dashed")
结果: