LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot 4D graph-different requirement!

Solved!
Go to solution

Hi All,

Let me explain my problem with an example. Suppose I have a data set as follows.

X-Axis              Y-Axis                   Z-Axis                   Color_Code

0                           0                            0                                  0

5                           5                             5                                 2

10                         5                            2                                 0

15                        9                            12                                 1

2                           14                          7                                  2

 

So each point is defined by its X,Y and Z axis values and an associated color_code.

lets assume that color_code=0 means red color

                              color_code=1 means blue color

                              color_code=2 means green color. I have only three color_code for now.

Each point should be plotted according to its color code.

How do I control the color parameter of the plot for each point? 

I was looking for an answer in the forum and came across this solution by DavidJCrawford. However it takes way too much time to plot my 2500+ data samples. Is there any other way to do it? 

Thank you.

Regards

Aveo

0 Kudos
Message 1 of 11
(4,745 Views)
Solution
Accepted by topic author aveo

What is the time you are looking for? I used the 3D Picture control with colored sphered to create a graph and I was able to get less then 1 s.

 

4DGraph.png

4DGraph_2.png

 

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 2 of 11
(4,727 Views)

Hi Barp,

Thank you for replying with a solution. It takes very less time to plot the 2500+ points.Smiley Happy

I made a few changes to your program to suit my requirements and came across a few problems. 

Problem 1: When i fix the Length parameter of Create 3D Axis.vi to 3, I am unable to plot a point whose axes values is greater than 3. This has been replicated in the attached vi.

Problem 2: I tried increasing the Length to 7(Can you please change it manually in the program to replicate it). Now the axes length increases but I am still unable to view the point(6,6,6).

Problem 3: I am not able to rotate/tilt the plot the way its possible when using 3D graphs.  

Hoping to solve the issues.

Regards

Aveo

0 Kudos
Message 3 of 11
(4,683 Views)

Another solution would be to use Surface Graph, if you're using the Full Development System.

 

Have a look at this post over here which describes how to use it to achieve a 3D surface with colour map.

 

Edit - doesn't change the size for each point, just the colour.

---
CLA
0 Kudos
Message 4 of 11
(4,667 Views)

Hi,

I went through the post. However the surface plot vi requires a 2D array for its Z matrix. I have a 1D array for the Z axis.

I want to plot points defined by (X,Y,Z). So in my case the Z axis has only 1D data. 

Is there any way i could still use plot surface to plot only points? 

Regards

Aveo

0 Kudos
Message 5 of 11
(4,658 Views)

You need to reshape the Z 1D array to be a 2D array of the X and Y array dimensions:

 


thoult wrote:

 

That's input terminals for X and Y arrays and a 2D Z array. These should all have matching dimensions: e.g. X has length m, Y has length n, Z should have dimensions m * n. That's the physical surface sorted.

 


 

---
CLA
0 Kudos
Message 6 of 11
(4,646 Views)

I am sorry but I do not understand how will reshaping and creating the Z matrix help me plot points?

The reason why Z is a 2D matrix is because it represents a plane/surface.

If I forcibly convert my points to surface then my plot is incorrect.

Imagine 2 points that lie on the same plane(i.e. have same value for Z), if I use the surface plot then both will show same color, isnt it?

But I want them to show different colors based on Color_code(refer my 1st post).

 

0 Kudos
Message 7 of 11
(4,641 Views)

My apologies - I forgot to mention that you should use the 3D Scatter Plot on the same palette and access the colour ramp settings via properties in the same way.

 

Your initial post, example data and subsequent post were unclear as to needing multiple colour values per Z. You should be able to achieve this with multiple plots in a 3D scatter plot and separate colour scales for both

---
CLA
0 Kudos
Message 8 of 11
(4,619 Views)
Solution
Accepted by topic author aveo

@aveo wrote:

Hi Barp,

Thank you for replying with a solution. It takes very less time to plot the 2500+ points.Smiley Happy

I made a few changes to your program to suit my requirements and came across a few problems. 

Problem 1: When i fix the Length parameter of Create 3D Axis.vi to 3, I am unable to plot a point whose axes values is greater than 3. This has been replicated in the attached vi.

Problem 2: I tried increasing the Length to 7(Can you please change it manually in the program to replicate it). Now the axes length increases but I am still unable to view the point(6,6,6).

Problem 3: I am not able to rotate/tilt the plot the way its possible when using 3D graphs.  

Hoping to solve the issues.

Regards

Aveo


first, right click the 3d plot and set the camera-control to "oriented":

2015-01-08_kamera control.png

 

 

then try to zoom out by pressing shift + drag the mouse during left-clicking

2015-01-08_zoom-3d.png

Message 9 of 11
(4,600 Views)

Hi @alexderjuengere,

Thanks a mighty ton for showing me the details of it. 

And thanks to @Barp for finding the awesome solution. It works wonders with medium size datasets in terms of execution time. I was trying to plot the 4D graph using another method suggested by @thoult 


@thoult wrote:

My apologies - I forgot to mention that you should use the 3D Scatter Plot on the same palette and access the colour ramp settings via properties in the same way.

 

Your initial post, example data and subsequent post were unclear as to needing multiple colour values per Z. You should be able to achieve this with multiple plots in a 3D scatter plot and separate colour scales for both

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I tried to plot the dataset as mentioned by thoult(it is being used by others also as seen here by @DavidJCrawford). However it was taking ages to execute- a dataset of 1000 points was taking around 30 minutes to get plotted on my 2 Ghz Core2duo PC(Sorry for the poor config) Smiley Sad

However the method by @Barp takes just a couple of seconds- Thumbs up! Smiley Happy

 

However I could not tilt/rotate the plot. Thanks to @alexderjuengere for providing the solution for that. 

I just want to add a few more snapshots to clear the procedure even more. 

 

Procedure to tilt/rotate/Zoom in/out of the garph

Step 0: Follow the guidelines given by @alexderjuengere in the previous post. Right click on 3d picture-> Camera controller-> check "orinted" and "Auto redraw". 

Step 1: Again go to the front panel. Bring the mouse over the 3D plot and Shift+ right click. You should see something like this. 

 

step1.png

 

Step 2: Click on the finger tool as shown in the image by the Blue rectangle.

 

step2.png

 

Step 3: To rotate/tilt- hover above the 3d picture and left click+drag.

Step 4: To zoom in/out- hover above the 3d picture, Shift+Left click+Drag 

 

Kudoes to all who contributed to this awesome solution! 

 

Regards

Aveo

 

Message 10 of 11
(4,569 Views)