LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple plots

 
Hello,
 
I wish to plot multiple  traces (up to 😎 on the same chart. I think my code is ok though I'd like to know if there's a better way than I chose.
I also need to know that I have used the array control correctly.
 
Thank you.
0 Kudos
Message 1 of 13
(4,303 Views)

 

Dear All,

Clearly I'm not very capable at all. I've incorporated the VI above into the main VI (I could have put it in as a sub VI but I prefered not to); it can be found in the "Aquisition" Case. Anyway it doesn't work. Can any clever body see what's wrong with it? Nothing is plotted although the x-axis of the graph does refresh at each step in the corresponding loop and the indicators do show values being created/transfered.

0 Kudos
Message 2 of 13
(4,286 Views)

If you want to show multiple traces, you're going all wrong about it.    The VI as it is now, will show only 1 value on the x-axis, namely the time delay that you set.  And on that x-value, it will show the first 8 x-values from your array... 

One trace is a cluster from an x-array and y-array.  To show multiple traces, you put those clusters in an array.  

Like this:

Message Edited by Anthony de Vries on 04-05-2007 06:05 PM

0 Kudos
Message 3 of 13
(4,277 Views)

 

 

Sorry,

I'm struggeling to understand what you mean.

I have an array of Y values which I need to plot simultaneously against a single X value at each step in the For loop (Number of Steps)  - that is as the data is created I want to plot it. I can't wait for the array to be generated before I plot it.

0 Kudos
Message 4 of 13
(4,271 Views)

OK the issue is that you are mixing the ideas of a chart and a graph.  There are some examples that show the difference, but basically a chart takes a single point at a time and adds it to the end of the plot.  The chart itself keeps a history, so you don't have to.  However a graph only displays the data you give it and has no history.  So you are giving the XY graph 1 point at a time, therefore you only get the one point.  You need to keep a history for yourself. See Anthony's reply to see how you can pass n arrays into the graph.

So add a few shift registers to the for loop, and build an array of positions for the x values, and then build an array of all the array3 values.  So as you get a new point you add it to then end of the arrays, and then you give those arrays to the bundle functions and then on to the graph.

0 Kudos
Message 5 of 13
(4,253 Views)

 

The question is, since I have a scaler as my X value and an array as my Y value where do the these "few" shift registers actually go. Is the aim to create an array of identical X values for each Y array? I'm all confused.

0 Kudos
Message 6 of 13
(4,245 Views)

 

 

 

The question is, since I have a scaler as my X value and an array as my Y value where do the these "few" shift registers actually go. Is the aim to create an array of identical X values for each Y array? I'm all confused.

0 Kudos
Message 7 of 13
(4,243 Views)
Here is a modification of your original VI.  Notice I am keeping 2 arrays, the X data array and then the 2D array of all the values.  I wrote this VI quickly, so you may need to look into memory usage, depending on how long you are running this VI.  Currently it just continues to build the arrays up that can lead to VERY large arrays.  If you have a max size that you are going to care about you can pre-alloate the arrays and then use replace array subset to fill them.
0 Kudos
Message 8 of 13
(4,237 Views)

 

Ok, here's the finished version. It's probably not much use to anybody without the same DAQ card as me but the code emphasises how important it is to know exactly what the variables being transfered to each function actually look like - that is, their dimensions.

Sections of the code might be useful to someone who is plotting several traces on a single graph as the data is generated. The most important point is to ensure the X and Y arrays that are to be "bundled" are the same size. This is what was causing the code not to work previously.

I'm sure some good sole's going to show me how I could have done it better.

0 Kudos
Message 9 of 13
(4,209 Views)
 
.............After such big words too. Well it's not the second time I've been wrong.
 
The last VI attached has a few mistakes in it, here's the corrected one which still doesn't work. My problem is that my voltage array (that I'm trying to bundle with my position array) is one element smaller than the position array. My method only generates n-1 values and not n.
 
Any suggestions would be really helpful. Thank you.
0 Kudos
Message 10 of 13
(4,187 Views)