LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to get multiple colours in an xy plot

Hi, I am creating an xy plot from two arrays (x and y) and I have a third array of equal size that contains a Pass/Fail boolean value. I am trying to make the plot so that if the data point "passes" it will be green, and if it "fails" it will be red. I tried to extract a sub array, but the passes and fails are randomly distributed, so I couldn't isolate the passes and the fails into distinct arrays. My second problem is that I would like the index number ( +1) to appear on the plot beside each point.
 
Thanks
 
Jeff
Jeff


Using Labview 7 Express
0 Kudos
Message 1 of 10
(5,664 Views)
You need to define two plots on your xy-graph. One green and one red.
 
You also need to make two arrays for the y values (or for the x-values, or both, but one is enough). Feed it through an autoindexing FOR loop containing a case structure connected to the boolean. Create two output arrays, one getting the data for TRUE and the other getting the input data for FALSE, both get NaN otherwise.
 
Now make two plots (x, y1 and x, y2). NaNs greate gaps so only one color shows at each position. If you use a line plot, you probably need to deal with edge effects to fill the gaps between transitions. Do you e.g. want to change the color of the line halfway between points?
 
You can label the points with annotations. What is your LabVIEW version.
Message 2 of 10
(5,659 Views)
Thanks, I am using Labview 7 Express. I am not making a line plot, it is a scatter plot of points, with a fairly random distribution of red and green. I will try to implement your suggestions.
 
Thanks
 
Jeff
Jeff


Using Labview 7 Express
0 Kudos
Message 3 of 10
(5,654 Views)

For a a scatter plot, you don't even need the NaNs.

Simply feed the x and y arrays into a loop as above and built new array pairs depending on the boolean. Here is one possibility:

I am not sure if LabVIEW 7.0 has annotation capability. How many points do you have?

Message Edited by altenbach on 02-16-2007 10:01 AM

Message 4 of 10
(5,647 Views)
Thanks, I used the NaNs to change the colours (Im new to labview, I've been teaching myself and I didnt know about NaNs) however I can't figure out the labelling, The number of points that I am dealing with could potentially change based on the user of the program, but it should generally be around 63.
 
Thanks
 
Jeff
Jeff


Using Labview 7 Express
0 Kudos
Message 5 of 10
(5,644 Views)
Create a property node for the xy graph and see if you have a property called "annotation list". I suspect it is not available in 7.0, but I could be wrong.
Message 6 of 10
(5,641 Views)
no, that option is not there in labview 7. I think I will instead make the index numbers appear beside each dot based on the cursor x and y position and the point x and y position. What would be the best way to monitor this? All I can think of is a for loop nested in a while loop that continously compares the cursor position with the point position, but I suspect that this will slow down my program significantly. Another question I had relates to the point style. Is it possible to change the points from being coloured dots to being filled circles of a user-defined diameter?
 
Thanks
 
Jeff
Jeff


Using Labview 7 Express
0 Kudos
Message 7 of 10
(5,637 Views)

You can change the point style to open circles. You can make them bigger by increasing the "linewidth" (a bit unintuitive, since you don't even show lines ;))

Annotations have been made much easier in newer version. For example we can even draw arbitrary things on the graph area using image commands.

One possibility for you would be to use an picture indicator instead of an xy graph. Here you have full control over anything at the cost of a bit more coding.

Message 8 of 10
(5,632 Views)
I tried changing the linewidth, and that worked to a certain extent, but the maximum linewidth is 5 (range 0-5) and that does not give me a big enough circle.
 
Jeff
Jeff


Using Labview 7 Express
0 Kudos
Message 9 of 10
(5,622 Views)
You can always generate the circle manually as curve segments seperated by a NaN, Attached is a simple draft (LV 7.0) on how you could do this. See if it makes sense. 🙂
 

I tend to use complex numbers for simplicity for 2D geometry. Newer LabVIEW versions can graph complex data as xy on an xy graph, making things even easier.

Message Edited by altenbach on 02-16-2007 12:57 PM

Download All
Message 10 of 10
(5,613 Views)