02-20-2020 05:57 AM
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?
02-20-2020 07:00 AM
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?
02-20-2020 07:14 AM - edited 02-20-2020 07:16 AM
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?)
02-20-2020 07:49 AM
@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.
I hope it's clear how the length can be changed. Make it an array to set the individual line lengths.
02-21-2020 01:43 AM - edited 02-21-2020 01:54 AM
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)
02-21-2020 02:30 AM
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.
02-21-2020 02:43 AM
hi,
i attach my vi. and the data file.
02-21-2020 03:27 AM
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.
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:
The XY graph will adjust automatically.