From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XY Graph, 2D Error Bar, Legend, Multi Plot Help? Please modify the VI

Solved!
Go to solution

PLEASE READ THE ENTIRE POST and HELP!

Please help with this VI and make it an instructive example for me and other novices like me who come across this typical example.

 

A typical problem in plotting data is as follows: On the SAME plot (Y-axis = Amplitude vs. X-axis = Time), plot the curves Amp1, Amp2, Amp3, ... coming from sample1, sample2, sample3, ...

 

Furthermore, there is Error1, Error2, Error3, ... associated with Amp1, Amp2, Amp3,...., which also needs to be plotted. In order to distinguish between these curves, one may use different

colors and show a legend that reads Amp1 (say black), Amp2 (say red), and Amp3 (say green). The plot then becomes complete and conveys data very conveniently.

 

The attached VI makes an attempt to plot Amp1 and Amp2 using XY Graph and also 2D Error Bar plot (to show error bars). There is one slight problem. The legend does not show what it is supposed

to show. Can someone fix this? If I plot two curves, the legend should show Amp1 and Amp2, if I plot three curves, the legend should show Amp1, Amp2, Amp3, and so on.

I don't want to see the default Plot 0, Plot 1, or whatever. Also, it would be nice to dynamically control the symbol, color, curve style etc, as we keep adding more and more curves to the plot.

 

Once this problem is fixed, I know I can easily extend it to make it plot more than just two curves in a dynamic way. I could use for loops with shift registers, etc to plot any number of curves on a single plot.

 

Believe me, I have searched for other posts and cannot find a simple example like the one I have posted here. Many examples I found have confused me more than helped me. 

I believe that if this problem is solved in a simple way, many others will find this example very instructive. So by helping me, you help many other people as well!

 

Thank you in advance. Please see the attached files (the VI, and an example data file that I just created)

Download All
0 Kudos
Message 1 of 4
(3,535 Views)

Some members have pointed out that this problem has already been resolved (see the link below).

http://forums.ni.com/t5/LabVIEW/Dinamically-handle-legend-names-using-property-nodes/td-p/1479572

 

I did verify that this works for XY Graph, but not for 2D Error Plot.

 

I need both legend and error bars. Shame on LabVIEW for not making such a basic plotting requirement easy and trasparent. 

There are many clever people who can find work arounds, but that is a not a correct approach. 

0 Kudos
Message 2 of 4
(3,506 Views)
Solution
Accepted by topic author murchak

If you like to graph multiple curves (Y1, Y2, Y3, etc.) with their respective error bars (Err1, Err2, Err3, etc) on the same plot 

using Error Bar Plot (aka 2D Error Bar), and want the legend to show (Curve1, Curve2, Curve3, etc. or whatever you want to call it),

please see the following link:

 

http://forums.ni.com/t5/LabVIEW/A-simple-challenge-Error-Bar-Plot/td-p/1986755

 

For using XY Graph, please see the link in one of the above posts.

 

Thanks to all that contributed to this.

0 Kudos
Message 3 of 4
(3,482 Views)

Thanks all for working through this example. 

 

It seems that the plot objects that are generated have somewhat limited customization capabilities from the front panel (e.g creating additional y-scales, sizing the plot rather than the frame around it).  

 

I thought about using multiple plots, rather than a multi-plot to implement graphing things at different Y-scales but the same x-scale.  However, when I remove the X-axis via properties. I get some pretty unexpected behavior:

2018-03-14_09-48-10.png

Has anyone done a deep dive into the underlying VIs in the 2D Plot class?    If so, would you be willing to share examples.  I don't need the front panel properties functionality.  The plot(s) will be fairly static in their properties, so I can code these properties up with lower level VIs.

The alternative would be to use the XY Error Graphing VI that is described in this thread:

https://forums.ni.com/t5/LabVIEW/A-simple-challenge-Error-Bar-Plot/td-p/1986755    A standard XY-Graph would be easier to customize, but the 2D Plot Objects seem to have better aesthetics.  

 

Thanks,

Jeremy

 

 

0 Kudos
Message 4 of 4
(2,751 Views)