LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting different data types in one XY Graph

Solved!
Go to solution

Hi there,

 

I am new to LabVIEW (and thus also to this forum), so forgive me if I ask something trivial, but I just can't solve it myself and I haven't been able to find the answer on the internet either.

 

In short: I am trying to plot a cluster of x- and y-location integer arrays (that can change in length over time), which should be plotted as a line, together with a single point (that changes location over time), of which I have the x- and y-location available as doubles, in one single XY Graph. This all happens within a while loop, and the values of the arrays and the doubles can change within this while loop, which should be plotted immediately in the XY Graph as well.

 

A little bit explanation: to get familiar with LabVIEW, I wanted to make a Snake game (you know, the game that used to be on all Nokia mobile phones). I've gotten pretty far, as I am now able to plot the snake moving through the XY Graph, and manipulating its movement with four (OK) buttons (up, down, left, right) on the front panel. It even becomes longer when it "eats" a "candy", adding a term to the integer array (blue bold line in the block diagram) describing the locations of the nodes of the snake. The arrays for x- and y-direction are clustered using a bundle-block, and are then fed to the XY Graph input. This all happens within a while loop that runs until the snake hits one of the borders of the graph or bites its own tail, in which case the loop is terminated ("game over").

 

The only essential thing that I still need to add, is the location of the "candy" within the XY Graph, which are two doubles (for x- and y-location) but can be transformed to integers. However, I don't know how to bundle the "candy" location together with the snake node locations in such a way that the XY Graph accepts this as input an plots the snake as a line and the candy as a dot. So far, I haven't even been able to get both snake and candy data in the same XY Graph altogether.

 

Does anybody know a solution to this? Your help is much appreciated!

 

Kind regards,

 

Joeri

0 Kudos
Message 1 of 5
(3,603 Views)

Hi Joeri,

 

I am trying to plot a cluster of x- and y-location integer arrays (that can change in length over time), which should be plotted as a line, together with a single point (that changes location over time), of which I have the x- and y-location available as doubles, in one single XY Graph.

Put this "single point" into the same data structure (cluster of X and Y array), then create an array of your two clusters. Each cluster will be presented as one plot in the graph…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,597 Views)

Hi GerdW,

 

Thank you for your response. I however do not understand how I should create an array of my two clusters. If I bundle the clusters and use the "Cluster to Array" block, I get the error message "Polymorphic terminal cannot accept this data type". Can you elaborate on what blocks to use to create this array of the two clusters?

Thanks in advance.

 

Kind regards,

Joeri

0 Kudos
Message 3 of 5
(3,587 Views)
Solution
Accepted by topic author jfrederik

Hi Joeri,

 

to create an array of two elements I would use BuildArray with just two inputs.

Simple and very basic stuff: did you take the "Getting Started" tutorials offered in the header of the LabVIEW board?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(3,570 Views)

Oh right, that IS very simple. I did do a lot of tutorials, but apparently I missed that one... Sorry about that! Thanks for your help, now it works exactly as I wanted! 🙂

0 Kudos
Message 5 of 5
(3,564 Views)