Hi,
You could add the file name as a tag before plotting the line and also add a Onclick callback. So when you click the line, you could code it to check the tag and probably change the file name and save.
Refer the following link to know more about Tag property of line. Plot3 and plot function both uses line object internally to create lines and hence you could set this property even with plot3.
Refer to the following link to know more about renaming file.