01-07-2015 03:23 AM
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
Solved! Go to Solution.
01-07-2015 09:03 AM
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.
01-07-2015 11:48 PM
Hi Barp,
Thank you for replying with a solution. It takes very less time to plot the 2500+ points.
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
01-08-2015 01:41 AM - edited 01-08-2015 01:43 AM
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.
01-08-2015 02:56 AM
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
01-08-2015 03:34 AM
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.
01-08-2015 03:47 AM
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).
01-08-2015 09:13 AM
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
01-08-2015 12:47 PM
@aveo wrote:
Hi Barp,
Thank you for replying with a solution. It takes very less time to plot the 2500+ points.
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":
then try to zoom out by pressing shift + drag the mouse during left-clicking
01-09-2015 12:47 AM
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)
However the method by @Barp takes just a couple of seconds- Thumbs up!
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.
Step 2: Click on the finger tool as shown in the image by the Blue rectangle.
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