LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I plot multiple points (scatter) on the same graph?

Solved!
Go to solution

Hello,

 

I have a graph with a fixed X-axis and an array of Y values which varies. How do I plot these new y values without replacing the previous ones? E.g to have a scatter of new data? Example of shown in Figure 1 below:

 

Figure 1: (Note: image was photoshopped to demonstrate goal) 

 

scatter goal.png

 

 

 

Figure 2: Current block diagram, LabVIEW VI:

 

Scatter.png

 

Thank you!

0 Kudos
Message 1 of 10
(6,752 Views)

See attached. (You need to duplicate your X values fed into the cluster.)

0 Kudos
Message 2 of 10
(6,736 Views)

Thanks Skydyvr. I think duplicating the constant (x axis) is tricky, because I would need a duplicate for every run. The runs are variable and bring in the new y-axis data. Please let me know if you have an alternative approach, i would greatly appreciate it, thanks 🙂 

0 Kudos
Message 3 of 10
(6,732 Views)

The obvious come to mind of just adding another plot for every run.

 

I don't think it would be that tricky. Because if you want to keep the data on just one plot, you would need to insert the new data points into your "new data array" anyway. You know what index you are inserting the new data points at. So you know the index to insert a duplicate X axis point also.

 

Actually I just tried this and it works. You can also add the new values to the end of the Y array. At the same time you add the X values to the end of the X array. This way you are not inserting elements into the array. Just adding new elements to the end of the array.

0 Kudos
Message 4 of 10
(6,727 Views)

Skydyvr, thanks again. However, I dont believe I follow. Im planning to use index 0 to 8 for my X-axis. Ive tried buliding a third for loop to place new x values with every new y value, but still no luck. Meaning I get new Y values, X-axis stays the same, but the data points dont accumulate, the graph only shows the most recent plot. Please demonstrate using a picture/VI, thanks. 

 

 

Scatterexpl.png 

0 Kudos
Message 5 of 10
(6,716 Views)
Solution
Accepted by topic author PSerial

Just build up a single plot:

 

ScatterPlotFP.pngScatterPlot.png

Message 6 of 10
(6,706 Views)

.

0 Kudos
Message 7 of 10
(6,705 Views)

Think about what you are really building. You are building an array of clusters, right? For each element in the array you have a cluster whos content has a value for the X axis and a value for the Y axis. As long as you are not connecting the datapoints in the graph (which you aren't), you can plot the datapoints in any order. If you are building your X portion of the cluster seperately than your Y portion of the cluster, you just have to make sure the indexes do not get transposed somehow.

 

Build the lower half of the attached picture, and you will see what I mean. (hopefully):smileywink:

Message 8 of 10
(6,703 Views)

Darin, that works like a charm, please clarify why you used the Re/Im to Complex node or how it generally plays into the overall result.

 

PS: Thank you both for all your help! 🙂

0 Kudos
Message 9 of 10
(6,694 Views)

LV stores a complex number (say double) and a cluster of two doubles in exactly the same way.  You can Type Cast seamlessly between the two, and the XY Graph is happy to graph them.  I use it here simply because a 1D array of Complex Double is easier to deal with the corresponding 1D array of clusters.

0 Kudos
Message 10 of 10
(6,687 Views)