LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Draw lines with a certain slope

Hi all! 

I want to draw on a XY graph straight line with certain slopes. The value of the slopes are in an array. 

 

Can you help me? 

0 Kudos
Message 1 of 8
(2,706 Views)

How is the slope defined (angle, or dx/dy, other)?

 

To draw lines, you'd also need a length. Do these lines all start from the same point, like a star? Or are they sequential (one after the other)?

 

Does each line (specified by an array of slopes) have a different length? Or the same length? Or the same dX? Or the same dY?

0 Kudos
Message 2 of 8
(2,679 Views)

The slope is defined as dy/dx. 

 

I would like that all these lines starts from the origin of the X and Y axis. 

 

All the lines should have the same length (how can I adjust it after?) 

0 Kudos
Message 3 of 8
(2,673 Views)

@Gquadro wrote:

The slope is defined as dy/dx. 

 

I would like that all these lines starts from the origin of the X and Y axis. 

 

All the lines should have the same length (how can I adjust it after?) 


Ok, so Let's start with 1 line.

 

p0 = 0, 0

I'd make a complex number from dy/dx (actually dx/dy), by using Re/Im To Polar.

Then, set the length to the desired value, by changing the r. The angle stays the same.

Get Re/Im (aka x/y). Put it in the array with P0.

That's one point

 

For n points, you need a few tricks.

 

The lines are not connected, they all share P0... So, although not needed, I want to avoid a line from P1 to P2, and from P3 to P4. These lines will overlap P0\P1 and P2\P3, but by inserting a NaN, this line will not be drawn at all. Feel free to remove this NaN.

 

The 2nd trick is that the XY graph accepts complex numbers.

Slopes Graph.png

 

I hope it's clear how the length can be changed. Make it an array to set the individual line lengths.

Message 4 of 8
(2,657 Views)

Attached you can find my .vi. 

there is something wrong because i have nothing in my graph

Can you help me?

 

Attach you can find what i would like to have in the end (slope=dx/dy)

Download All
0 Kudos
Message 5 of 8
(2,613 Views)

I'm stuck in LV18, so I can't open that VI. If you save to previous, or post an image, I can have a look.

 

In the meanwhile you can place probes to see if there is data going into the XY graph. I expect that one array is empty, but that's just a guess. Turning execution highlighting on might help as well.

 

The multiple colors can't be done in one plot (e.g. one array). That requires a plot for each color. So you'd have to make a 2D array, or an array of XY array clusters.

0 Kudos
Message 6 of 8
(2,605 Views)

hi, 

i attach my vi. and the data file.

Download All
0 Kudos
Message 7 of 8
(2,601 Views)

In the for loop, you're building an array. But the P0 is an empty array. So the result is P1's and NaN, not P0, P1, NaN.

 

Right click the empty array in the for loop, and change it to element. Optionally do this for the NaN as well. Both don't need to be arrays, although they can be. But the P0 can't be an empty array. Either give it 1 element, or change it to an element (scalar).

 

That gives 3 lines with the attached data, but they overlap.

Slopes Graph (array).PNG

I know your focus is on other things, but this is a good moment to straighten those lines.

 

If you want a plot for each line, change it to:

Slopes Graph (plots).PNG

The XY graph will adjust automatically.

0 Kudos
Message 8 of 8
(2,591 Views)