LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple plot XY graph

Hello,

 

I am facing a problem with displaying multiple plots on a single XY graph.

 

2015-07-20 12_20_44-PANTALLA_last.vi Block Diagram on exe.lvproj_My Computer _.png

 

I use Build Array to build array of two 1d arrays of clusters with X and Y values.

Unfortunately, the effect is that I can see both plots, but they are realy single plot (the same colour, etc.).

 

DADES_CORVA is empty, so the only thing that we sould see is plot 0,0 to 50,50. As you can see below it is the same colours as Plot 0, also when I hide Plot 0 it disappears.

 

2015-07-20 12_20_44-PANTALLA_last.vi Block Diagram on exe.lvproj_My Computer _.png

 

Where is the problem? In my opinion it should be Plot 1 with thick green line.

Thank you for your support.

0 Kudos
Message 1 of 10
(10,396 Views)

Hi Pawel,

 

your cluster array wire holds an array of cluster of XY point.

 

First mistake: each plot should consist of a cluster of an X array and a Y array (as is shown in the help of the XY graph!)

Second mistake: your BuildArray node is set to concatenate the inputs, instead of building up an array. This way you still have just one plot in the array…

3rd mistake: When you want to show a plot, which consists of just one point you should change the plot properties to also show points…

Best regards,
GerdW


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

Hello GerdW,

 

@1 I know this - but lets assume that this part of the code (that is supposed to create first plot) has to remain this way - is it possible to add second plot generated correctly, not messing with the rest of the code?

 

BR

0 Kudos
Message 3 of 10
(10,348 Views)

Hi Pawel,

 

is it possible to add second plot generated correctly

No, the XY graph does NOT accept a 2D array of points.

 

not messing with the rest of the code?

You can create your own "glue code" to convert the array of points to cluster of X/Y array. Then create an array of cluster of X/Y array to have more than one plot in your graph:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 10
(10,314 Views)

Hello GerdW,

 

When I try to do this with just one plot, there is error as below - it looks like graph demands 1d array of cluster, not cluster of 2 arrays.

 

2015-07-20 12_20_44-PANTALLA_last.vi Block Diagram on exe.lvproj_My Computer _.png

BR

0 Kudos
Message 5 of 10
(10,277 Views)

Hi Pawel,

 

that's just because your abuse of local variables!

Get rid of the local variable (of the graph) and the problem is gone too!

 

Background: the graph terminal will adapt to several datatypes as can be seen in my image above. The local variable will only support the datatype that is currently wired to the terminal - and CANNOT adapt to other datatypes…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(10,273 Views)

There are bigger problems here than the Graph itself.

Why do you use a case structure with a Boolean constant True wired to it? what is the purpose?

You are overusing local variables. Use data flow. Go through the tutorials and online courses, you will see it will get much easier to program in LabVIEW.

 

 

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

 

http://www.ni.com/newsletter/51735/en/

0 Kudos
Message 7 of 10
(10,271 Views)

@PawelS wrote:

Hello GerdW,

 

When I try to do this with just one plot, there is error as below - it looks like graph demands 1d array of cluster, not cluster of 2 arrays.

 

2015-07-20 12_20_44-PANTALLA_last.vi Block Diagram on exe.lvproj_My Computer _.png

BR


Please attach your actual code. We cannot debug pictures (for example what is in the array constant you are using to initialize the shift register? What are the dimensions of the various arrays?

 

Your array operations are overly complicated for such a simple task. To get rows or columns, use "index array".  Instead of "inerset into array" use "built array". "Index array" is resizable and you don't need to wire the indices if you want the elements in order. You can combine the of.c.input/if_ini and of.c.out/of_ini scalars first so you only need one array operation.

 

You don't need a shift register at all. I would recommend to use complex data for xy graphs.

 

Where is the local variable data coming from?

 

Please attach your VI containing typical data in the various controls/indicators. Thanks!

Message 8 of 10
(10,222 Views)

Thanks for the tip about complex data, Altenbach, I did not know you could do that before. When putting multiple plots on the same graph, is the following example the correct way to do it? It seems odd to bundle the data into a cluster by itself, but it works.

 

complex data.png

0 Kudos
Message 9 of 10
(10,196 Views)

@Gregory wrote:

It seems odd to bundle the data into a cluster by itself, but it works.


Use "build cluster array" instead. Less clutter, same difference! 😄

 

 

 

(ouf course if you create the plots on an autoindexing loop boundary, you need to use the plain bundle inside the loop)

Message 10 of 10
(10,183 Views)