Rs= [20, 20, 20, 20]
Ls = [20, 30, 40, 50]
times = [t/10.0 for t in range(0,100)]
for R, L in zip(Rs, Ls):
I = [m.exp((-R/L)*t)-1 for t in times]
plt.plot(times,I)
plt.legend(str(L))
我希望得到20,30,40和50的图例,但是5和0出现了。我的代码出了什么问题?
Rs= [20, 20, 20, 20]
Ls = [20, 30, 40, 50]
times = [t/10.0 for t in range(0,100)]
for R, L in zip(Rs, Ls):
I = [m.exp((-R/L)*t)-1 for t in times]
plt.plot(times,I)
plt.legend(str(L))
我希望得到20,30,40和50的图例,但是5和0出现了。我的代码出了什么问题?
1条答案
按热度按时间xytpbqjk1#
使用
plot()
的label
参数,并在循环外部调用legend()
:输出: