Tag to each point on wave?

I want to attach to each point in graph a tag from a text wave.  So, I have a wave with N points displayed in graph and a text wave with N strings. I just wrote ugly code which generates unique tag for each point. It's not difficult or long, just ugly.  Which got me wonder, is there easier way? 

How about text markers? They won't have the little arrows connecting them to the data points, but it's an easy way to associate strings with data points.

Here is an example:

 

make/n=10 ddd=x
make/t/n=10 ttt
•ttt=num2str(p)+"_Point"
display ddd
ModifyGraph mode=3,textMarker(ddd)={ttt,"default",0,0,5,0.00,0.00}

 

In reply to by Igor

Jan,

I had to do something like this recently and here is my solution; tags are connected to points with an arrow.  In may case, the final tag position had to be redone manually as plot was a scatter plot where spacing between points was not consistent.  Note that the trace that was to be labeled was hard coded although the tag wave was not.  Finally, this function will add or remove all the tags based on an input flag parameter.

I'll let you decide if it's ugly or not. 

Jeff

Function ShowPointLabelsOnGraph(wTags, nFlag)
    Wave/T wTags
    Variable nFlag  //create 1 or kill 0 tags
   
    Variable nIndex
    Variable nNumPoints
    String sSampleName = ""
    String sTagID = ""
    String sTagText = ""
   
    nNumPoints = DimSize(wTags, 0)
   
    for( nIndex=0; nIndex < nNumPoints; nIndex += 1 )
        sTagID = "SampleName_" + num2istr(nIndex)
        sSampleName = wTags[nIndex]
        sprintf sTagText, "\\Z08%s" sSampleName
       
        if( nFlag == 1 )
            Tag/C/N=$sTagID/F=0/A=LB/TL={len=10,sharp=0.25}/I=0 CoF#1, nIndex,sTagText
        else
            Tag/K/N=$sTagID
        endif
    endfor
End

 

Thanks!

I have similar code for the ShowPointLabelsOnGraph, may be not so clean and nice ;-)

Text markers are much more interesting! I need to center the marker on first characters, since I want to put in the first character something which looks like point and center that where the real position is. I am trying to figure out how to get that configured. That is what I call simple method... 

Thanks!

 

Edit: easy solution. Append same data twice, once with normal marker and once with offset text marker. This is actually very readable and easy solution. Much cleaner and easier to maintain, no loops, names creation... Thanks!