Editing multiple annottions

I have many spectra plotted on a graph, each with its own label (annotation).
Is there a way to select all the annotations and edit the text (for example font size)?

Thanks

Rahul

They follow the graph size (Modify Graph...) if that helps.

This might also help:


#pragma TextEncoding = "Windows-1252"
#pragma rtGlobals=3		// Use modern global access method and strict wave access.
#include <AnnotationInfo Procs>

Window TestGraph0() : Graph
	PauseUpdate; Silent 1		// building window...
	Display /W=(155.25,51.5,549.75,260) jack
	ModifyGraph zColor(jack)={jack,*,*,Grays}
	TextBox/C/N=text0/A=MC/X=0.46/Y=18.96 "\\Z18This is an annotation with a fixed size"
	TextBox/C/N=text1/A=MC/X=-25.23/Y=44.55 "This is an annotation with no size"
	TextBox/C/N=text2/A=MC/X=-3.24/Y=-3.32 "\\Zr150This is an annotation with a relative font size"
	Tag/C/N=text3/X=1.62/Y=-16.11 jack, 38, "Tag with default font size"
	Tag/C/N=text4/X=6.12/Y=4.86 bottom, 64, "tag connected to bottom axis"
	ColorScale/C/N=text5/A=MC/X=43.75/Y=13.74 trace=jack
	AppendText "Default size axis text"
	Legend/C/N=text6/J/X=24.77/Y=11.37 "\\s(jack) jack is a legend (default font size)"
EndMacro

Menu "Graph"
	"-"
	Submenu "Annotation Font Sizes"
		"6 points",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 6, 0)
		"8 points",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 8, 0)
		"10 points",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 10, 0)
		"12 points",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 12, 0)
		"16 points",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 16, 0)
		"24 points",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 24, 0)
		"-"
		"50%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 50, 1)
		"66%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 66, 1)
		"75%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 75, 1)
		"88%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 88, 1)
		"\\M0::100% (default)",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 0, 0)
		"125%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 125, 1)
		"150%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 150, 1)
		"175%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 175, 1)
		"200%",/Q,  ChangeAnnotationsFontSize(WinName(0,1), 200, 1)
	End
	"-"
End

Function ChangeAnnotationsFontSize(win, newFontSize, isRelative)
	String win // graph or layout
	Variable newFontSize // points or percent. Use 0 to remove font size from annotation.
	Variable isRelative // if true, then newFontSize is relative font size in percent

	String list = AnnotationList(win)
	Variable i, numBoxes = ItemsInList(list)
	for(i=0;i<numBoxes;i+=1)
		String thisBox = StringFromList( i, list )
		String infoStr = AnnotationInfo(win, thisBox )
		String text = AnnotationText(infoStr)
		text= RewriteAnnotationTextSize(text, newFontSize, isRelative)
		String type = AnnotationType(infoStr) //  "Tag", "TextBox", "ColorScale", or "Legend"
		String cmd=""
		strswitch(type)
			case "Tag":
				String ywave= AnnotationYWave(infoStr)
				Variable xAttach= AnnotationAttachX(infoStr)
				sprintf cmd, "%s/C/N=%s %s, %.14g, \"%s\"", type, thisBox, ywave, xAttach, text
				break
			case "ColorScale":
				// ColorScales have a font size that's normally 0 (graph font size)
				// in addition to the axis label \Z stuff
				// so they're not adjusted here.
				break	// comment out this line to treat the axis label of a Colorscale just like a Textbox
			default:
				sprintf cmd, "%s/C/N=%s \"%s\"", type, thisBox, text
				break
		endswitch
		if( strlen(cmd) )
			Execute/Q/Z cmd // remove /Q if you want to see the executed commands
			//Print cmd
		endif
	endfor

End


Function/S RewriteAnnotationTextSize(text, newFontSize, isRelative)
	String text 		// TextBox/C/N=text2/A=MC/X=-3.24/Y=-3.32 "\\Zr150This is an annotation with a relative font size"
	Variable newFontSize	// 0 to remove font size, 18 for 18 point, 150 for 150%
	Variable isRelative 	// if true, then newFontSize is relative font size in percent
	
	// rewrites only the initial font size escape code in the text.
	Variable slashZrStartPos = strsearch(text, "\\\\Zr" , 0)
	Variable slashZStartPos = strsearch(text, "\\\\Z" , 0)
	// handle the case where the text has both \\Z and \\Zr
	Variable startPos, endPos, foundRelative=0
	if( slashZrStartPos >= 0 && slashZStartPos >= 0 )
		if( slashZrStartPos <= slashZStartPos ) // == if only \\Zr
			startPos= slashZrStartPos
			foundRelative=1
		else
			startPos= slashZStartPos
		endif
	elseif(slashZrStartPos >= 0)
		startPos= slashZrStartPos
		foundRelative=1
	else
		startPos= slashZStartPos
	endif
	if( startPos >= 0 )	// \\Z found
		if( foundRelative )
			endPos = startPos + strlen("\\\\Zrnnn")-1 // note: strlen("\\Z") is only 2
		else
			endPos = startPos + strlen("\\\\Zdd")-1
		endif
	endif
	
	String replaceWith=""
	if( newFontSize )
		if( isRelative )
			sprintf replaceWith, "\\\\Zr%03d", newFontSize
		else
			sprintf replaceWith, "\\\\Z%02d", newFontSize
		endif
	endif
	if( startPos < 0 )
		text = replaceWith + text
	else
		text[startPos, endPos] = replaceWith
	endif
	
	return text
End

--Jim Prouty
Software Engineer, WaveMetrics, Inc.