In the previous article, I described the process to create a 3D Scatter Plot using a 3D Orthographic View matrix and the SGPLOT procedure. I posted a macro that can be used to create a 3D scatter plot from any SAS data set, using 3 numeric columns, one each for X, Y and Z (Response) axes.
Visualization of 3D data can be improved by providing interaction or animation. Here I have described a way to create an animation using the idea described in the previous article.
The setup for the animation is as follows:
options papersize=('5 in', '4 in') printerpath=gif animation=start animduration=0.05 animloop=yes noanimoverlay; ods printer dpi=100 file='C:\Class3DScatterAnim.gif'; ods listing image_dpi=200; ods graphics / reset attrpriority=color width=5in height=4in imagefmt=GIF; %run_anim_macro(data=sashelp.class, start=-30, end=-60, incr=-1); %run_anim_macro(data=sashelp.class, start=-60, end=-30, incr=1); options printerpath=gif animation=stop; ods printer close;
I have modified the %Ortho3D_Macro provided in the previous article, and added a loop to render multiple graphs with changing value for the Z-Rotation from -30 to -60 and back by 1 degree. Here I have created a GIF animation. An SVG animation can also be created using the code at the bottom of the attached file.
3D Animation Macro: Ortho_3D_Animation
Matrix Multiplication Function: Matrix_Functions