Python 使用最小和最大范围的时间戳绘制ax.axhline

Python 使用最小和最大范围的时间戳绘制ax.axhline,python,matplotlib,Python,Matplotlib,我试图画出一段特定时间内的水平线 我的df的索引是DatetimeIndex # This plot a horizontal line: ax.axhline(df.threshold[0], 0, 0.25). #but the range (min, max) is not precise) # This doesn't plot any line nor give any error message ax.axhline(df.threshold[0], df.index[0],

我试图画出一段特定时间内的水平线

我的df的索引是DatetimeIndex

# This plot a horizontal line:
ax.axhline(df.threshold[0], 0, 0.25).   #but the range (min, max) is not precise)

# This doesn't plot any line nor give any error message
ax.axhline(df.threshold[0], df.index[0], df.index[50])
非常感谢您的帮助

只需使用:

ax.hline而不是ax.axhline