Does matplotlib have a function for drawing diagonal lines in axis coordinates?

后端 未结 4 2105
生来不讨喜
生来不讨喜 2020-12-28 12:55

Matplotlib Axes have the functions axhline and axvline for drawing horizontal or vertical lines at a given y or x coordinate (respectively) indepen

4条回答
  •  长情又很酷
    2020-12-28 13:23

    Starting from matplotlib 3.3.0, it will: https://matplotlib.org/3.3.0/api/_as_gen/matplotlib.axes.Axes.axline.html

    Axes.axline(self, xy1, xy2=None, *, slope=None, **kwargs) Add an infinitely long straight line.

    The line can be defined either by two points xy1 and xy2, or by one point xy1 and a slope.

    This draws a straight line "on the screen", regardless of the x and y scales, and is thus also suitable for drawing exponential decays in semilog plots, power laws in loglog plots, etc. However, slope should only be used with linear scales; It has no clear meaning for all other scales, and thus the behavior is undefined. Please specify the line using the points xy1, xy2 for non-linear scales.

提交回复
热议问题