Detect error bars?

Is there a way to detect whether or not error bars have been applied to a trace in a graph? The recreation macro generated by the "traceinfo" command does not appear to contain any error bar options, and I cannot see any other way to get the status of or information on traces in a graph.
You can do it using WinRecreation.

For example, to find out whether Error Bars are present in a Graph you can use the following Function:
strsearch(WinRecreation("Graph0",0),"ErrorBars",0)
It returns -1 if no error bars are present in Graph0, otherwise it will be positive.

and more specifically, the Function:
strsearch(WinRecreation("Graph0",0),"ErrorBars wave0",0)
returns positive if error bars are on trace wave0 in Graph0.

I have not checked whether this works in all cases.

Hope this helps!
Kurt
Indeed, the presence of flags for things like the bar and cap width would cause problems with the simple check for "ErrorBars wave0". Here's a function that does the trick:

Function ErrorBarsArePresent(gname, trace)
	String gname, trace
	
	if (strlen(gname) == 0)
		gname = WinName(0,1) // top graph window
	endif
	
	if (strlen(trace) == 0)
		return strsearch(WinRecreation(gname,0),"ErrorBars",0) >= 0 // simple existence of error bars
	endif
	
	String winrec = WinRecreation(gname,0)
	Variable nlines = ItemsInList(winrec, "\r")
	Variable i
	for (i = 0; i < nlines; i += 1)
		String oneline = StringFromList(i, winrec, "\r")
		if (strsearch(oneline,"ErrorBars",0) >= 0)
			if (strsearch(oneline, trace+" ", 0) >= 0) // space prevents finding trace "wave0x" when you ask for "wave0"
				return 1
			endif
		endif
	endfor

	return 0
end

The input "gname" is the name of a graph window. Use "" to apply this to the top graph window.
The input "trace" can be "" to check for the simple presence of error bars on any trace in the graph. Otherwise, it names a trace like "wave0" or "wave0#1".
The code views the recreation macro as a list of command lines separated by carriage returns.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thanks for this code, I found this helpful myself as well.

I've made a similar function to actually return the TraceName of the Error Bars. This function could no doubt be written better, but hopefully it can help someone just as the above code helped me.

To work, this function assumes that your error bar is a +/- wave on the Y variable.


Function/S ErrorBarsTraceName(gname, trace)
// copied mostly from ErrorBarsArePresent on IgorExchange
	String gname, trace
 
	if (strlen(gname) == 0)
		gname = WinName(0,1) // top graph window
	endif
 
	if (strlen(trace) == 0)  // you should always pass a trace name so that code does not come here
		return ""
	endif
 
	String winrec = WinRecreation(gname,0)
	Variable nlines = ItemsInList(winrec, "\r")
	Variable i
	for (i = 0; i < nlines; i += 1)
		String oneline = StringFromList(i, winrec, "\r")
		if (strsearch(oneline,"ErrorBars",0) >= 0)
			if (strsearch(oneline, trace+" ", 0) >= 0) // space prevents finding trace "wave0x" when you ask for "wave0"
				oneline=StringFromList(2,oneline,",")
				oneline=StringFromList(0,oneline,")")
				return oneline
			endif
		endif
	endfor
 
	return ""
end
// ErrorBarsTraceName
Igor 6.31 reports the ErrorBars command in the TraceInfo output. Igor 6.30 was the first version that does that.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.