plt.legend在函数中如何使用

def showData(x):
    length = len(x)
    t = np.arange(0, length*10,10)
    plt.plot(t, x)
showData(x=Data)
showData(x=DataMdl)
showData(x=Sour)
x = np.arange(0,ite)
plt.plot(x*dt,Tw)

不知道如何去增加四条曲线的plt.legend()图例

lines = []
def showData(x):
    length = len(x)
    t = np.arange(0, length*10,10)
    line = plt.plot(t, x)
    lines.append(line)
showData(x=Data)
showData(x=DataMdl)
showData(x=Sour)
x = np.arange(0,ite)
plt.plot(x*dt,Tw)
#handles 线条的实例对象
#labels 图例的名称
#loc 图例位置(一般选取'best'这个参数值)
plt.legend(handles=lines, labels=['线1','线2','线3','线4'], loc='best')