vertical & horizontal lines in matplotlib

后端 未结 3 1379
有刺的猬
有刺的猬 2020-11-29 21:27

I do not quite understand why I am unable to create horizontal and vertical lines at specified limits. I would like to bound the data by this box. However, the sides do not

3条回答
  •  难免孤独
    2020-11-29 21:51

    The pyplot functions you are calling, axhline() and axvline() draw lines that span a portion of the axis range, regardless of coordinates. The parameters xmin or ymin use value 0.0 as the minimum of the axis and 1.0 as the maximum of the axis.

    Instead, use plt.plot((x1, x2), (y1, y2), 'k-') to draw a line from the point (x1, y1) to the point (x2, y2) in color k. See pyplot.plot.

提交回复
热议问题