import numpy as np
import matplotlib.pyplot as plt
AB = np.random.randn(100,2) #create a random array of [[A1,B1],[A2,B2],...] as example
x = np.linspace(-100.,100.)
fig,ax = plt.subplots()
for ABi in AB:
A,B = ABi
ax.plot(x, A*x+B )
ax.set_xlim((-100.,100.))
ax.set_ylim((-100.,100.))
plt.show()
1条答案
按热度按时间yxyvkwin1#
要在x和y的某个指定范围内绘制两条直线,可以这样做:
假设你用
[[A_1, B_1] , [A_2, B_2], .. ]
来表达这个问题,建议你想绘制一个不同的线的数组,那么你可以像这样使用for
循环来绘制: