Automatically Add Annotations

// Adds a legend and a tag for each trace to the specified graph.
// Example:
//  Make/O/N=10 wave0=p, wave1=p+1, wave2=p+2
//  Display wave0, wave1, wave2
//  AutoAddAnnotations("")
Function AutoAddAnnotations(graphName)
    String graphName            // "" for top graph
   
    Legend/C/N=legend0      // Add legend
   
    String traceList = TraceNameList(graphName, ";", 1)
   
    Variable index = 0
    do
        String traceName = StringFromList(index, traceList)
        if (strlen(traceName) == 0)
            break               // All done.
        endif
       
        Wave w = TraceNameToWaveRef(graphName, traceName)
       
        String tagName = "tag" + num2istr(index)
        Variable pointNum = numpnts(w)/3
        Variable xAttach = pnt2x(w, pointNum)
       
        Tag/C/N=$tagName/F=0/M/L=2/X=20/Y=40 $traceName, xAttach, "\\ON: \\OY"
       
        index += 1
    while(1)
End

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More