11-14-2019 12:23 PM
Hi,
I am new to PCA and have installed the Analytics Package and I am working with my Python PCA expert. The Python expert does not know LabVIEW.
I have a set 57 parts that consists of 3 different types.
Code has been created to generate the plot below. The code is also below.
How do I assign a color to each point to represent the part type?
Thanks in advance!
12-19-2019 01:39 PM
Let me see if I understand what you are trying to do.
You want to separate the data found in the array and assign it to one of the 3 different types. Each type has its color and all of them would be displayed in the 3D Graph, similar to the one below. Is this correct?
12-19-2019 02:04 PM
I generally have a measurement array, 2 to 5 part types that has 801 data points for each part type.
a) I would like to color each point the same color for the respective part.
b) Have the points in the PCA display identify as the serial number of the measurement.
Best Regards,
Carl Bohman
12-19-2019 03:23 PM
Something you could do is to programatically separate each part type from your measuremnt array into different arrays, each containing a part type. This would help you, because now you will be able to make a plot for each part type in the 3D graph. Then you can assign a color to each plot by right clicking on the graph, going to the 3D Plot Propperties, and in the Scatter category you can custom the Color Ramp for each plot. This way every part type will have its own color and would be displayed in the same graph.
For example, here I generated a 2D array(Axis,Measurements). The measurements total size is 30, and each part type is 10 data long. Each iteration at the for loop on the right, separates the array into 2D subarrays of 10 measurements. Then the array is indexed into the Plot Helper to create a plot. For this example the 3D graph creates 3 plots, but it can be greater by increasing the number of measurements. This way it doesn't matter how many measurements you have, it will always create a new plot for every 10 values.
The output of the graph is actually this:
12-19-2019 03:29 PM
Also a way to programmatically assign the color of the 3D Graph is by creating a property node of it and setting the color you want by doing this:
I hope this works for you.
Regards,
Diego Grajales
01-07-2020 10:30 AM
Thanks for the reply Diego.
I'm not sure that is what I need.
Let's assume I have an array of data taken D(m,n); where m are the total samples and n is the data associated with each sample.
Suppose in the samples I have D(1-5,n) being one sample set and D(6-10, n) ... to D( m-sample set size, n). I then create a PCA plot of the D.
How do I assign a color for each sample set so that it show in the 3d PCA plot?
Regards,
Carl Bohman
01-07-2020 02:16 PM
Hi Carl,
Searching for PCA Graphs I found out that actually the groups of data of the same color are separated by plots. And having each set of data inside a plot and then add each plot to the same Graph (in this case a 3D Graph) is the only way I know of assigning colors to groups of data. You can then assign a color to each plot and this way they would be visually separated.
Lets take your example of the D(m,n) array. In this case, you would have to separate the array into different plots, where each sample set would have its own plot. If the sample sets have the same amount of samples every time, using any kind of Loop is the best way to do this. But by using a 3D Graph this gets a little bit trickier as you need to use the Plot Helper.vi for each iteration.
The code I sent you earlier is an example of how to create a multiple-plot 3D Graph. It just needs to be modified to accurately divide the data array into its sample sets within each iteration.
I really hope this information helps you.
Diego Grajales
01-07-2020 03:10 PM
Look Carl, here I used the same code to divide data as before but I created a more specified data array that I think is more similar to PCA plotting.
My array has 6 samples with 10 measurements of data associated to each sample. Sample sets are made of 2 samples each, so I know that my sample set would have 20 measurements of data.
By running this VI I get the following results. I guess this resembles more a PCA Plot that the previous one.
Does this contain the needs of your application? Or maybe you are looking for a different aproach.
01-08-2020 12:21 PM
I created your sample .vi and I was not able to create your result.
01-08-2020 12:27 PM
Then attach your VI as it is likely you did something differently. But no one can point out the issue when you don't show your code.