LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Place Multiple Data Sets on One Graph (LabVIEW to Excel)

Solved!
Go to solution

I'm reading in a 2D array (first row X-axis values, 2nd row Y-axis values, 30 columns each) from a number of existing excel files. With each iteration of my for loop, I read in 1 set of this 2D array data, and I'm graphing it (using Excel Insert Graph) before I close this file and move onto the next one. 

 

What I want however, is to be able to generate 1 graph at the end with all the sets of data together. So far, each time I'm iterating through, the new data erases the old one, and at the end I only get 1 set of data (the last set) on 1 graph. 

 

I searched through similar topics on the forum, but 1) I don't have all my data read or typed into a nice big table, they come in iterations instead, 2) my data values don't share the same x-axis values, although the range is almost the same (say from 0 to 1) and the number of data points is always 30, 3) I don't think I can use shift registers because all my data is obtained within my for loop, when I open the Excel files (also within the loop) and read from them, hence I don't have "Original Data" to initialize the shift register.

 

Any suggestions on how I could read data, graph it, read new data, then graph on the same graph without losing my old data?

 

Thanks!!

0 Kudos
Message 1 of 8
(7,414 Views)

You can plot several data sets on one graph using an array of clusters.

 

In your loop, where you read files and extract the x values and y values, add a bundle element and expand it to accept two inputs.

wire the x values array to the first input, and the y values to the second input. 

wire the output from the bundle element to the right side of the loop. make sure the terminal is set to auto-indexing. 

 

when the loop has finished all its iteration it will output an array of clusters that define all your plots. You can wire this to a waveform graph element.

 

Hope this can be of help to you!

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
Message 2 of 8
(7,391 Views)

Thanks for the input Jarle, but I'm still a bit confused. 

 

I've plotted several data sets on one graph (waveform graph) onto the front panel using your method. However, what I need to do now is not to output them onto a front panel graph, but to write them to a graph inside Excel. I'm using the Report Generation Toolkit, but keep running into problems as mentioned in my original post.

Message 3 of 8
(7,341 Views)

Hello Kalyie,

 

The attached is a slightly modified shipping example that shows how to plot muliple graphs on one plot in excel.

The input to the Excel Insert Graph.vi accepts a 2D array. Have your X values as the first row of your 2D array, all subsequent rows will be ploted as Y values. You can accomplish this with the Build Array primitive.

 

Hope this helps!

 

Thanks,

Joel C

National Instruments

Message 4 of 8
(7,316 Views)

Thanks Joel, but I still have yet to solve the problem with point 2) of my original post: each set of data has a unique set of X-axis values and corresponding Y-axis values. No two sets are exactly the same. 

0 Kudos
Message 5 of 8
(7,289 Views)
Solution
Accepted by topic author Kalyie

Kalyie,

 

You may need to coerce your data to have the same X-axis.

 

Another option may be to insert data into excel instead of a graph. Then from inside excel you could have a graph set up that knows where the X and Y values are for each data set and it will plot it automatically.

 

You may also try messing around with the Excel Update Graph.vi.

 

I have had mixed success with the Excel Update Graph.vi, but it is worth a look.

 

Thanks,

 

Joel C

National Instruments

0 Kudos
Message 6 of 8
(7,268 Views)

sorry to bring up old post,

 

but is there any real solution (vi example) for this problem?

 

regards,

Yan. 

0 Kudos
Message 7 of 8
(6,921 Views)

Hi Yan,

To increase traffic on your issue, I recommend creating a new post. Also, it would be helpful to clarify what part of the last post your question pertains to. There are multiple issues discussed in this post. The more information you can give us the better. Hope this helps!

Regards,

Michelle G
Applications Engineering
National Instruments
0 Kudos
Message 8 of 8
(6,903 Views)