Legends with more wave info

I would like an option for the default legend in a graph to include the data folder, in addition to the name, of each wave in the graph. Ideally this would include control over whether to include the complete path, or only the name of the containing folder (though if I had to choose one, I would definitely prefer to have just the containing folder). The documentation frequently refers to organizing projects as multiple runs in folders, where the waves have identical names, and indeed I find this a very useful approach. But it requires hand-tweaking the graph legends to distinguish the waves from each other (or writing special functions, as shown in the Data Folder Tutorial experiment).

Similarly, I would greatly appreciate if the legend included x waves when XY pairs are plotted.
I'd also greatly appreciate such a datafolder in legend feature. I have a lot of Igor experiments that have the same wavename in a large number of folders so that the current default legend has no meaning and I need to change it frequently.

Ideal would be 3 options: the wave name only, the data folder only (maybe with two versions like getdatafolder(1) and getdatafolder(0)), and both, wavename and folder.

Currently I'm using this code for it:


function folder_legend()

variable i
variable noftraces = itemsinlist(TraceNameList("",";",1))
string legendstr = ""

for(i=0;i<noftraces;i+=1)
     legendstr = legendstr + "\\s("+stringfromlist(i,TraceNameList("",";",1))+") " + GetWavesDataFolder(WaveRefIndexed("",i,1) , 1 ) +"\r"
endfor

legend/C/N=text0/J legendstr
end