LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot a 3D Graph of recorded data (x, y, z) with no connecting lines or axis showing

 I'm trying to plot points of 3D data in the 3D graph without showing the lines to connect the data.  Also, I'm trying to turn off the axis grid lines and labels.  I'm only concerned about the shape of the data.  My code is below, and it plots, but is very hard to read due to the issues above.  I've looked a the examples and help file, but still can't find my issue 

 

CA_VariantSet1DArray (&var_x, CAVT_DOUBLE, ref_array_length * loop_cnt, x_array);
CA_VariantSet1DArray (&var_y, CAVT_DOUBLE, ref_array_length * loop_cnt, y_array);
CA_VariantSet1DArray (&var_z, CAVT_DOUBLE, ref_array_length * loop_cnt, z_array);
 
GetObjHandleFromActiveXCtrl (sat_panel_handle, SAT_FORM_SAT_VIEW_3DGRAPH, &threeDgraphHandle);
CW3DGraphLib__DCWGraph3DGetPlots (threeDgraphHandle, NULL, &threeDplotHandle);

CW3DGraphLib__DCWGraph3DPlot3DCurve (threeDgraphHandle, NULL, var_x, var_y, var_z, CA_DEFAULT_VAL); 

CW3DGraphLib_CWPlot3DSetStyle (threeDplotHandle, NULL, CW3DGraphLibConst_cwPoint);

CW3DGraphLib_CWAxis3DSetVisible (threeDgraphHandle, NULL, VFALSE);

 

Thanks for any help you can give

 

Ryan

 

0 Kudos
Message 1 of 8
(5,656 Views)

Ryan,

 

If you do not want your data points to connect to one another, you will have to graph NaN values, this is an example of graphing NaN values in Measurement Studio. As for the other question on how to turn off the grid, have you tried using the property ATTR_XGRID_VISIBLE and ATTR_YGRID_VISIBLE. There is also a similar ATTR_XLABEL_VISIBLE that can be used for toggling if you can see the labels. 

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 2 of 8
(5,627 Views)

I guess I should have noted that I'm programming in CVI. 

 

I've determined how to turn off the entire grid, but not how to show only axis as x, y, and z vectors. 

 

There isn't a way to plot the data at X,Y, and Z points similar to a scatter plot in excel?

 

Thanks

 

Ryan

 

0 Kudos
Message 3 of 8
(5,623 Views)

Ryan,

 

I noticed you were using CVI, just wanted to show you the concept that I was referring to. Also the graphing controls behave the same for measurement studio and CVI. You can plot points in 3D by putting them between NaNs. For instance if you wanted a point at [1,1,1]  and another at [2,2,2] then your x, y , and z arrays would need to be [NaN, 1, NaN, 2, NaN]. Without the not-a-number constants, CVI has no way of knowing that you do not wish to connect the points. Graphing with NaNs between your numbers would provide you with a 3D scatter plot. 

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 4 of 8
(5,614 Views)

I added to following code to fill array with NAN when the data is (0,0,0).  This does not remove the lines.    

  

 if (rect_x[i] == 0 && rect_y[i] == 0 && rect_z[i] == 0)
          {
           x_array[j * ref_array_length + i] = NotANumber ();
           y_array[j * ref_array_length + i] = NotANumber ();
           z_array[j * ref_array_length + i] = NotANumber ();
          }
         else
          {
           x_array[j * ref_array_length + i] = rect_x[i];
           y_array[j * ref_array_length + i] = rect_y[i];
           z_array[j * ref_array_length + i] = rect_z[i];
          }

 

I was able to use the edit property of the graph to display the scatter points (like I orginally requested), but now the redraw speed is very slow when comparing it to the default settings of the graph.

 

Thanks

 

Ryan

 

 

 

0 Kudos
Message 5 of 8
(5,610 Views)

Ryan,

 

Here is an example of how to plot discontinuities including holes and scatter type graphs in 3D with CVI

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 6 of 8
(5,597 Views)

I implemented code to insert NAN values between each x,y,z datapoint and after graphing, no data showed up on the graph.  I don't see anything special or different in the example you showed except for the graph data function

 

I'm using: 

CW3DGraphLib__DCWGraph3DPlot3DCurve (threeDgraphHandle, NULL, var_x, var_y, var_z, CA_DEFAULT_VAL);

 

The example uses

CW3DGraphLib_CWPlot3DPlot3DSimpleSurface (plotHandle, NULL, vArray, CA_DEFAULT_VAL);

 

I don't see a way to use a different graphing fuction because I have 3 very large arrays (256K long) of data in x,y,z coordinates which need to be scatter plotted.  Like I mentioned before, I can fix this issue by selecting point plot in the graph properties, but then the zoom and rototate functions are incredably slow in comparison to graphing a surface and seeing the connected lines (which I don't understand).  Any other ideas for either graphing the data differently or speeding up the zoom/rotate?

 

Thanks

 

Ryan

 

0 Kudos
Message 7 of 8
(5,584 Views)

Ryan,

 

If you're plotting 3 x 256k coordinates, calculating and rendering 256,000 points with 768,000 associated numbers dynamically as you pan and zoom, there could be more overhead as opposed to rendering an interpolated surface. In my example you have to change the graph properties to choose points, otherwise you will see nothing, i set it to do this automatically to avoid confusion. If you would like to whittle your code down to a community example and post it to ni.com/community and post a link on this thread I can take a look and see if there are any obvious ways to speed up the rendering, but it may just be that plotting so many points takes up a large amount of overhead. 

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 8 of 8
(5,565 Views)