matplotlib绘制一条与x轴形成固定角度的直线

问题描述:

我有一个固定点,我想绘制一条穿过这个固定点的直线,并且还会使45度角,即斜率1与x轴一致。matplotlib绘制一条与x轴形成固定角度的直线

我该怎么做matplotlib?

这可以设置情节“平等”,并使用正确的坐标的纵横比,例如(你也可以使用ax.set_aspect):

import matplotlib.pyplot as plt 

xs = [1,2] 
ys = [0,1] 

ax = plt.subplot(aspect='equal') 
ax.plot(xs, ys, '-') 
ax.set_xlim(0,5) 
ax.set_ylim(0,5) 

plt.show()