07-30-2021 11:12 PM
Hello members,
I am wondering how I could use error bar in my XY graph. I read a couple of very old posts regarding the error bar plots, but I could not find those or related properties in XY graph. Was it removed or any advanced features came up in the newer version?
If anyone has recently used error bars, kindly let me know where I can find it and how to use it.
Thanks,
Pradeep.
07-31-2021 09:12 AM
What is an "Error Bar"? If I have a point P at a coordinate (x, y), one way to plot an "error bar" showing ±e at the point P is to draw a line from (x, y+e) to (x, y-e). If you want to be fancy, and put little "hats" of width "h" at the top and bottom of the error bar, that's two more lines, from (x-h, y+e) to (x+h, y+e) and (x-h, y-e) to (x+h, y-e).
What a pain! No, not really -- simply write a sub-VI called "Error Bar" with three Inputs: the Array of Points [P], another Array of Errors [E], and a "hat width" (h). Inside, you have a For loop that does the above calculations and draws the Error Bars on the Graph.
Oops, "on the Graph" -- you need one more input, a reference to the Graph. To keep your sub-VI "neat", I recommend using the standard 4-2-2-4 Connector Pane, with Error In and Error Out on the lower corners, P, E, and h on the left edge, and the Graph Reference on the top left input.
Have fun. It shouldn't take you very long to create this sub-VI. Oh, definitely do make it a sub-VI, if for no other reason than you might want to put Error Bars on more than one Graph, or may want to do this again a month from now ...
Bob Schor
07-31-2021 12:20 PM
Hi Bob Schor,
Thank you for the immediate reply. You sounded very easy and I hope it is. Although I did not understand the 3rd paragraph '4-2-2-4', I will give it a good try. Many thanks.
Pradeep.
07-31-2021 10:25 PM
Pradeep,
My apologies for being obscure. Here is the explanation: When you create a new VI (for example, by typing ^N), you get a blank Front panel, and in the upper right-hand corner, a "Generic NI Icon" and the Default Connector Pane, a square with four smaller squares on the left edge, followed by two 1x2 rectangles, two more 1x2 rectangles, and four more 1x1 squares. This is the "4-2-2-4" Connector Pane, which I use for almost 100% of the VIs and sub-VIs I create (even those that only have Error In and Error Out). Indeed, there is a good argument to be made for using no more than 1 or 2 Inputs (not counting Error In) and a similar small number of outputs (not counting Error Out) in most of the VIs that you write. [Don't get me started on notions of LabVIEW "Style" ...].
Bob Schor
08-01-2021 01:08 PM
@Bob_Schor wrote:
What is an "Error Bar"? If I have a point P at a coordinate (x, y), one way to plot an "error bar" showing ±e at the point P is to draw a line from (x, y+e) to (x, y-e). If you want to be fancy, and put little "hats" of width "h" at the top and bottom of the error bar, that's two more lines, from (x-h, y+e) to (x+h, y+e) and (x-h, y-e) to (x+h, y-e).
What a pain! No, not really -- simply write a sub-VI called "Error Bar" with three Inputs: the Array of Points [P], another Array of Errors [E], and a "hat width" (h). Inside, you have a For loop that does the above calculations and draws the Error Bars on the Graph.
Oops, "on the Graph" -- you need one more input, a reference to the Graph. To keep your sub-VI "neat", I recommend using the standard 4-2-2-4 Connector Pane, with Error In and Error Out on the lower corners, P, E, and h on the left edge, and the Graph Reference on the top left input.
Have fun. It shouldn't take you very long to create this sub-VI. Oh, definitely do make it a sub-VI, if for no other reason than you might want to put Error Bars on more than one Graph, or may want to do this again a month from now ...
Bob Schor
reminds me of this:
08-01-2021 06:01 PM
Error bar...? Limit lines?
08-01-2021 11:56 PM
I was a bit curious as to how 'easy' this actually was, so I put together a VI to generate a second plot from a first plot using the Complex Double datatype as the input.
This has some nice advantages in allowing potentially error bars with X too, but I didn't implement that here (the errors are just Double values).
To allow multiple plots, you'd need to change the input datatype, or perhaps just run this VI inside a For loop and concatenate the outputs.
The VIs are saved for 2019.
Pradeep, the key points here (you may already know this, but I'll write anyway) are
09-21-2021 12:44 PM - edited 09-21-2021 12:46 PM
Hi all,
Thank you for your feedback.
I feel it is over complicated. I already have data that is acquired from different instruments. The array is of 3 columns. [Xdata Ydata Yerr]. I don't need hat width, Xerr, pos/neg error. The columns are of absolutely the same array size. The data is attached. As and when the data points are generated, I would be plotting it in XY graph using shift register.
I can make X, Y, E, Y+E, Y-E and plot (X,Y) represented by 'x', (X,Y+E) represented by '-', and (X,Y-E) represented by '-'. The XY plot can be connected with a colored line, while the other two can be connected with transparent line. I may only need to connect the (X,Y+E) with the corresponding (X,Y-E). Is this possible?
Thank you.
Pradeep.
09-21-2021 02:01 PM
If I understand what you are saying, you are making some simplifying modifications of what CButchter and I both suggested. You are using "symmetric" Error Bars (so the bar goes up the same amount as it goes down, drawn as a line, which is what I think you mean by "-") and plotting the central data point (second column) as a symbol (which you call "x"). Give it a go, it is quite straight-forward.
Something you might find simplifies things is to do the plot in two passes.
Bob Schor
09-21-2021 11:22 PM
Hi Bob_Schor,
I wanted to use "-" minus/hypen sign for symbol in Error bar points, while "x" sign for central data point. While I could find "x" sign, I could not find "-" sign in the XY graph properties. Is it possible to have "-" sign or any other sign that is not listed in the properties?
My next question is, I don't know how to draw vertical lines from (x,y+e) to (x,y-e). Please let me know.
Thank you.
Pradeep.