LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XY graph multi plot with single x and multiple Ys

Solved!
Go to solution

Hello,

 

I need to do a XY graph with 8 curves (plots), the 8 plots share the same X axial, so the data array is (X, Y1, Y2, ... Y8), I can do the XY graph with 8 plots by making 8 pairs of (X, Y1), (X, Y2), .. (X, Y8), which is for 8 single plots, then bundle the 8 pairs of data for a multiple plot. 

 

I would like to know if  there is any way to do it without making 8 pairs of (X,Y) and directly to do the XY graph with multiple plots? 

 

Thanks,

Gu 

Message 1 of 34
(8,707 Views)

@edmonton wrote:

I would like to know if  there is any way to do it without making 8 pairs of (X,Y) and directly to do the XY graph with multiple plots?  


No. (If you really think this would be useful, vote for this idea ;))

 

Of course if the x-values are spaced equally, you would just set the x0,dx according to the X values and graph the rest as plain 2D array on a waveform graph instead.

 


@edmonton wrote:

.. so the data array is (X, Y1, Y2, ... Y8),  


Your description of the data is ambiguous. Is this a 2D array where columns are for each set? Can you attach a simple VI with typical data?

 

0 Kudos
Message 2 of 34
(8,682 Views)

Hi Altenbach,

 

Thank you for your reply in the weekend.

Each  set of data (X, Y1, Y2, ...Y8)  is from an online stream serial port reading from 8 channels of different data acquisition devices. The X is the time at which the 8 channels are read. The time interval (delta X) between two consecutive stream reading is not even, hence must use XY graph. 

 

Making 8 pairs of (X, Y) data then bundle them for multiplot XY graph can do the work. However, the overhead is heavy when the data streaming rate is high, say over 100 streaming points per second, making CPU too busy, especially when data acquisition, logging into a spreadsheet and display are simultaneously, which is a common application.  

 

It would be better if there is a way that a multiplot xy graph VI can handle this situation directly. 

 

Regards,

Gu  

0 Kudos
Message 3 of 34
(8,670 Views)

Addition:

 

The total number of data will be very high if the online data streaming is longer then 10 minutes at 100 streaming points per second. taking 10 minutes as an example, total number of xy data points is 100X8X60X10 = 480000. it would be very challenge for a computer to update XY graph online.

 

Gu 

0 Kudos
Message 4 of 34
(8,668 Views)

addition:

I tried to do multiplot as a post's suggestion, not successful.

Here is the link to the suggestion.

https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Even-Simpler-Multiplot-XY-graphs/idi-p/1393286

 

Attached is a sample program (XY_2D_ver1.vi) including data generation, logging and display, similar to my application. The program finds 3 numbers greater than 0.5, 0.75 and 0.95 and then repeating the process. Each set of 3 number occurs at different time, forming (X, Y1, Y2, Y3) series. I want to do the XY graph with 3 plots without duplicating 3 pairs of (X, Y1), (X,Y2) and (X,Y3).  

 

Could someone help with the issue?

Gu

 

 

0 Kudos
Message 5 of 34
(8,646 Views)

I'm working directly from the code you posted.  I notice that you have a Wait function in there to get the loop to run once/second, returning the first value that exceeds 0.5, 0.75, or 0.95 in that second.  You are sampling very fast, so there's no worry that one or more loops will not stop with a value in a second.

 

First, note the simplification of the While loops, wiring the Stopping condition directly to the Stop terminal.  The logic at the bottom of the Loop measures the loop time (which should be very close to 1000 msec).  Also, we get Loop Count directly from the Loop Index, no need for a Shift Register.

 

When the Loop ends, we compute the mean dt (which should be 1.000 or 0.999) and its Standard Deviation (which should be small), and use it to build three Waveforms (true, the delta-t's are not identical, but it's the best Windows can do, and should be "good enough" for your purposes.  Now combine the three Waveforms into an Array and plot on a Waveform Chart.  No Graph needed.

 

Bottom Line -- really try to take measurements at equal (and identical) time intervals.  This example code readily allowed this, so I used it.

 

Here's a Snippet:Multi-Plot Version 2Multi-Plot Version 2Bob Schor

0 Kudos
Message 6 of 34
(8,642 Views)

@edmonton wrote:

the overhead is heavy when the data streaming rate is high, say over 100 streaming points per second, making CPU too busy, especially when data acquisition, logging into a spreadsheet and display are simultaneously, which is a common application.  

 

It would be better if there is a way that a multiplot xy graph VI can handle this situation directly. 


Let's take a look at these claims, specifically.

 

First, we can acknowledge that we aren't using a deterministic method to read these.  As a result, we're going to have some jitter error built into the reading.

 

Next, we can point out you've stated this problem only exists as you increase the sampling rate.  This has a number of implications.  You're pointing out this requires more processing.  You're missing the higher the sampling rate here, the shorter the delta between any two data points gets.  The smaller that number gets, the less of an absolute difference you'll see between delta1 and delta2.  As that absolute difference diminishes, you see less value from the XY-Graph versus a Graph.  Why?  If you place the data point 1 second away it becomes a greater distortion than if it's 0.01 seconds away.

 

What you're trying to do doesn't really require the XY-Graph. The problem you run into only exists once you take away the value you're getting from this design choice.  

 

As a way to verify this, take a typical data set where you're running into issues.  Take the data and place it into two different displays: XY-Graph and Graph.  Look at the two and see how visibly different the plots are.

0 Kudos
Message 7 of 34
(8,635 Views)

Hello Bob,

Thanks for your effort. Your way works, but not exactly what I wanted.

I need live updating the XY graph at time when each set of new data is obtained. Your graphed it after the whole data generation/collection. What I need is a XY graph within the for loop or a while loop.

 

The 1000 ms wait was for me to watch the process for troubleshooting. In real application, no such a need.

 

Regards,

Gu 

 

0 Kudos
Message 8 of 34
(8,633 Views)

Hello natasftw,

 

I really appreciate your time on writing the comment. 

 

Here attached is a statistical result of time interval between 2 consecutive streaming data collections, 9,700 streaming data were obtained over 105 second, averaging 92 streaming data per second. The majority of the time interval was approximately 10.7 ms, but there were some spikes as shown. 

 

The test was done with 2 active channels only, the time interval and its distribution will change when 8 channels are involved. In addation, no signal processing was involved for the test. I need to add signal filtering at least to smooth data, which requires CPU resource. Hence, I am wondering if there is a better way of plotting the XY graph.  

 

The data sampling was from  serial ports of third party data acquisition devices, They do not have hardware timed data acquisition, data streaming was software based, this is the reason that a fixed sample rate is not possible, the more data collected the longer time interval is expected.

 

Regards,

GU

  

 

Regards,

Gu

 

 

 

 

 

 

0 Kudos
Message 9 of 34
(8,624 Views)
Solution
Accepted by topic author edmonton

Hi edmont,

 

I need live updating the XY graph at time when each set of new data is obtained.

Then you need to place the graph inside the loop.

You need to build the plots in the loop. (In your VI you forgot to collect the previous plot data in a shift register…)

 

When you worry about loop iteration times:

- Don't use a Windows computer. RT targets offer much less jitter. FPGA provides even less jitter…

- Don't do any file operations within your DAQ loop! Especially not those "easy" ones which open and close the file in each iteration…

 

Suggestion:

Learn about the Producer-Consumer pattern. It really helps to separate DAQ loop from File handling and also from GUI handling…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 34
(8,598 Views)