LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Implementing/using XY Graph

I have a quick question.  I am trying to plot data using "XY Graph".  My data for the x-axis is being acquired from data inside a 2 column listbox and the data for the y-axis is being acquired from a 2-D array which I am traversing using a FOR loop.  The two problems I have are:  (1)  The array of points which represent the x-axis are not showing up on my graph.  (2) I am not able to get any data (from the 2-D array I am traversing) plotted.  Attached is a diagram of how I am wiring the graph. 
 
Any help is greatly appreciated.
 
 
0 Kudos
Message 1 of 11
(3,757 Views)
Your fundamental problem is not understanding how loops work. You have the graph indicator inside the loop, which means that, at best, you will only see the results of the last iteration. The XY Graph is not "cumulative". If you are trying to create a multi-plot XY Graph you do not need a for-loop. Open the Example Finder (Help -> Find Examples) and search for "graph". You will find several examples that show you how to create graphs, expecially multi-plot XY graphs.

Also, it is highly unlikely that you need to use a local variable to reference those controls/indicators. In all likelihood, a wire will work just as well.
0 Kudos
Message 2 of 11
(3,748 Views)
I see what you are saying with respect to where the XY graph was originally placed and how it will be continually updating my plots.  The reason for the FOR loops was because the variable "ValuesToBeGraphed" is a 2D array and eventually I will be building multiple single plot graphs (it's a customer requirement).  Each 1-D array within "ValuesToBeGraphed" will eventually be its own single plot graph. 
 
I updated my vi (a picture is attached) so that there are no FOR loops and I'm only plotting one row of data (the 1-D array at index 1) from "ValuesToBeGraphed".  However, I am still get the same error.  The y-axis will scale correctly with regards to what points are supposed to be plotted.  However, I still don't see any actual data points (attached is a picture of the graph I get).  Also, for some reason there is no x-axis points either (which are being acquired from my multicolumn listbox). 
Download All
0 Kudos
Message 3 of 11
(3,735 Views)
I have several guesses as to what is going on, but rather than going back and forth with "are you doing this", or "try this", it's easier to look at the VI directly. With the data loaded in the controls, right-click on the controls and select Data Operations -> Make Current Values Default. Save the VI and upload it. This will allow me to run the VI with the actual data.


0 Kudos
Message 4 of 11
(3,722 Views)
Attached is my vi  (see the attached testgraph2.vi).  I have disabled a portion of the vi because it requires multiple input files. 
 
As a heads up, the vi requires you to enter in data before it will continue forward:
 
(1)  Under the "Path" control you can choose any folder since I have disabled the portion of the code that needs the data.
(2)  Under "Choose Number of Test Points" choose three test points.
(3)  Under the multicolumn listbox, enter three values (these are what is supposed to be plotted on the x-axis of the graph)  under the "Angle of Attack" column. 
 
On a side not, I tried copying the code  that just handles plotting on the graph to a seperate/new vi and it worked fine(see attached testgraph.vi).  So I am not entirely sure where the error is occuring.
 
Thanks for the help
Download All
0 Kudos
Message 5 of 11
(3,712 Views)
There is something really bizarre going on with your VI, and I'm not talking about the code, which is, well, we'll skip that for now.  Smiley Wink

Every time I try to place a graph, any kind of graph, the X scale graticule disappears. This happens with any graph. Furthermore, when I tried to copy your code and place it into a new VI the block diagram went over, but no front panel ojects were visible. The terminals were there on the block diagram, so the objects were part of the VI, but none of them were visible. The scrollbars were there, but the thumb controls disappeared. Yet, I could scroll with the up/down controls. It's just that nothing was showing up on the pane. Double-clicking on the terminals switched to the front panel as if it was trying to take me to that control/indicator, but there was nothing to see. And no, they weren't set to be hidden.

Like I said, really bizzare. I suspect NI would be interested in seeing this behavior.

They may recommend that you recreate the VI without copying and pasting code.

0 Kudos
Message 6 of 11
(3,694 Views)
Thanks for you help.....I ended up making the vi again and now the XY Plot seems to work fine.....I am not sure what the issue was but I did make an effort to use fewer local variables for this implementation.......
0 Kudos
Message 7 of 11
(3,681 Views)
Hi All,

I took a look at the VI posted and I did not see any of the behavior you guys are mentioning. The one thing I can think of is that there is a local variable which is created from an array indicator. The actual indicator is really far away in a lower corner. Maybe when you copied the code in a different VI you must have not copied the array indicator and that is probably the reason why everything was acting up.

Eli S.
National Instruments
Applications Engineer
0 Kudos
Message 8 of 11
(3,637 Views)
The VI was written in 8.2.1. Did you open the VI in that version, or in 8.5?

I reopened the VI based on your comments. The scroll bars do indicate the existence of an array indicator off in the top left, but not that far away. Its terminal and local variables are contained within the large sequence frame. When I copied the code all I did was drag and drop the overall sequence frame, which copied everything. As far as I could tell, anyway.

However, that still doesn't explain why placing any new graph on the original VI caused the graph's time axis to lose its graticule.
0 Kudos
Message 9 of 11
(3,633 Views)
I had opened in LV 8.5 and I just checked in 8.2.1 and I also did not encounter any problems. As far as the indicator it is pretty far away from the rest of the code and I had to drag it several times before I was able to get it to the vicinity of the rest of code. I also created a new graph as well and it looked exaclty the same as a new graph on any other VI. In which version did you open this? Also, did you save it to your hard drive or did you just opened from the forum post (which downloads a temp. version)?


Eli S.
National Instruments
Applications Engineer
0 Kudos
Message 10 of 11
(3,610 Views)