LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

plotting two y plots on the same x axis

Solved!
Go to solution

Hi all,

 

relatively new to labview, and finding the plotting aspect very difficult to get my head around.

 

I have three 1D arrays:

 

X: 1D array of x values (double) - called Axis in the VI

Y1: 1D array of y values (int32) - called Histogram in the VI

Y2: 1D array of y values (double) - called Gaussian Fit in the VI

 

The y arrays both correspond 1-1 with the x array. I want to plot them on the same plot, with Y1 as a column plot and Y2 as a line plot. Can someone point me in the right direction? Specifically I need to know what chart type to use, and how to combine the three arrays into clusters or something that the plot type can recognize.

 

Let me know if more information is needed. I have also attached my code so far, as well as a sample data set. Basically I want to comine the two plots into one. When you run it it will ask for a file - feed it the .csv file and enter "1" in the dialogue box when it asks how many header lines there are.

 

Thanks!

Download All
0 Kudos
Message 1 of 11
(6,679 Views)
Solution
Accepted by topic author kbriggs

Step 1: get rid of the sequence structure and local variables and hidden controls/indicators. None are needed.

Step 2: Have a look at the top picture here on how to graph xy plots that share a common x axis.

Message 2 of 11
(6,651 Views)

Here's an example / tutorial. 

 

Edit: Altenbach beat me again!

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 11
(6,647 Views)

What is he VI he is using to combine the arrays?vi.png

 

Never mind, got it - it just looked different on the pallete

0 Kudos
Message 4 of 11
(6,631 Views)

Build Array...

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 5 of 11
(6,628 Views)

@altenbach wrote:

Step 1: get rid of the sequence structure and local variables and hidden controls/indicators. None are needed.


Here's how the code could look like without the sequence structure, without the locals, without all the hidden indicators, and some of the Rube Goldberg code streamlined. THere are significqantly more simplifications possible, this is just a literal rewrite, all flow is the same. If you used the hidden indicators as crutches to remind you of the data name, use wire labels instead. The wire is the data!

 

 

 

 


altenbach wrote:

Step 2: Have a look at the top picture here on how to graph xy plots that share a common x axis.


Of course xy graphs accept a large variety of datatypes (array of xy point clusters, cluster of xy arrays, 1D complex arrays, cluster arrays of complex arrays, etc.), and creating multiple plots differs somewhat depending on datatype.

 

 

0 Kudos
Message 6 of 11
(6,591 Views)
mainly I was using hidden indicators because I was printing them out as I went as a debugging tool to make sure that everything was working at each step. (They were not hidden at the time). I am a C programmer initially, so the flat case structure was a way to add some modularity to the code and make it a little easier to follow for my own sake. I guess the dominant paradigm with LabVIEW is very different. Thanks for the tips.
0 Kudos
Message 7 of 11
(6,560 Views)

You can easily leave the same indicators connected to the wire for troubleshooting, there is still no need for local variables.

For direct open-brain surgery troubleshooting while the VI is running, just use probes. 😄

0 Kudos
Message 8 of 11
(6,557 Views)

I guess I understand the point being made in the .png above, but is it not more readable with the flat sequence structure? I'm learning so I'm sure there are good reasons for doing it like that, but what are they? It seems like you are sacrificing readability for streamlining the dataflow, but when the program run in <1s regardless does it matter much?

 

EDIT: I'm not referring to the rube goldberg cleanup - obviously I have a lot to learn manipulating arrays through loops and I am making my life more difficult than it could be. I just mean the reduction in modularity in general.

0 Kudos
Message 9 of 11
(6,539 Views)
Your code was not modular, just fragmented. For modular code you would combine functional units into subVIs. 🙂
0 Kudos
Message 10 of 11
(6,516 Views)