# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Unable to plot 1-D array with a cluster of 2 elements on an XY graph

I'm Unable to plot a 1-D array with a cluster of 2 elements on an XY graph. The data appears at the input to the graph but nothing is plotted. I'm trying to plot a line connecting each point generated.

Message 1 of 10
(3,107 Views)
Solution
Accepted by topic author chuck72352

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

You need a shift register on the inner For Loop as well.

But beyond that, you are creating too complicated of a structure.  You are creating multiple 1 point plots rather than a single multipoint plot.

See attached for the modification that works.

Message 2 of 10
(3,099 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

Chuck,

0. Do not post VIs with infinite loops! Change the True constant to a control.  One of the regular participants on these Forums has commented that using the Abort button to stop a VI is like using a tree to stop a car.  It works, but may have undesired consequences!

1. Use a shift register on the For loop also.

2. Inserting into an empty array leaves you with an empty array.  Initialize the array outside the loop to a size greater or equal to the maximum size you will be using.  Then use Replace Array Subest inside the loop.

3. Just make an array of the cluster of points.  No need for the extra cluster.

Lynn

Message 3 of 10
(3,097 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

When checking your code I found some problems:

• If you change the point style to be something (like a filled point) in the plot you will see one point jumping "around".
• If you change the tunneling to shift-register on the input and output of the FOR-loop you will be able to add values to the array BUT now you are adding a new plot each iteration (creating a multiplot). Drag out the Plot Legend to see all the 10 plots (one point / plot).
• ...

Well what is really the issue? Do you want to a multi plot (which you are trying to do) XY-graph or just one single plot (with multiple values)?

/Marcus

______________________________________________

Marcus Törndahl (System Architect)
Message 4 of 10
(3,090 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

If I did want to keep my original structure, that is a 1-D array of clusters with two elements and plot multipoints to one plot would that be possible?  I tried to do it and wasn't able to.

Message 5 of 10
(3,064 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

The output of your VI is a 1D array of clusters with two elements. Is there an easy way to save that data to a file? I'm guessing I have to remove the cluster from the array, then remove the data and put it into another array and then save it to a file as usual.

Message 6 of 10
(3,061 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

There are several different ways of sending data to an XY graph.  Open up the example finder and look for "XY Graph".  That shows 4 different datatypes for sending the data between arrays and clusters.  Which way is best depends on whether you want a single plot or multiple plots.

As for sending the data to a file, you probably will need to unbundle data, combine arrays, convert to strings (assuming you are looking for a text file), before writing the data to a file.  Exactly what way to do that depends on your datatype for the graph and how you want the data to look in the file.

Message 7 of 10
(3,057 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

Here's my attempt

Message 8 of 10
(3,054 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

I'm not sure what you are attempting.

You are building and array of clusters, fine, but then just indexing out that last element and breaking apart the cluster and building a 1-D array of the 2 element in the cluster.

If you want to get a 2-D array of your data, then just do this.

Message 9 of 10
(3,050 Views)

## Re: Unable to plot 1-D array with a cluster of 2 elements on an XY graph

I found a method that seems to work. See attached.

Message 10 of 10
(3,048 Views)