Tag each point of a trace


Function TagAllPoints(graphName, traceName, tagTextWave)
	String graphName			// "" for top graph
	String traceName			// Name of graph trace to be tagged.
	Wave/T tagTextWave
	
	if (strlen(graphName) == 0)
		graphName = WinName(0, 1)
	endif
	if (strlen(graphName) == 0)
		Abort "There are no graphs"
	endif
	
	Wave w = TraceNameToWaveRef("", traceName)
	Variable n = numpnts(w)
	
	Variable i
	for(i=0; i<n; i+=1)
		String text = tagTextWave[i]
		Variable xval = pnt2x(w, i)
		String name = "tag" + num2istr(i)
		Tag/C/N=$name/W=$graphName/F=0/L=1 $traceName, xval, text
	endfor
End

Function RemoveAllTags(graphName, traceName)
	String graphName			// "" for top graph
	String traceName			// Name of graph trace to be tagged.

	if (strlen(graphName) == 0)
		graphName = WinName(0, 1)
	endif
	if (strlen(graphName) == 0)
		Abort "There are no graphs"
	endif
	
	String list = AnnotationList(graphName)
	Variable numItems = ItemsInList(list)
	Variable i
	for(i=0; i<numItems; i+=1)
		String name = StringFromList(i, list)
		String info = AnnotationInfo(graphName, name)
		String typeStr = StringByKey("TYPE", info)
		if (CmpStr(typeStr,"Tag") != 0)
			continue
		endif
		String tagTraceName = StringByKey("YWAVE", info)	// "YWAVE" is a misnomer - it is really a trace name
		if (CmpStr(tagTraceName,traceName) != 0)
			continue
		endif
		Tag/K/N=$name		// Remove the tag	
	endfor
End

 

Forum

Support

Gallery

Igor Pro 10

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More