Point Cloud Plot For Environmental Data

© A.I. McLeod, February 2002

In this notebook we show how to create a point cloud to represent 4 dimensional data.  The 4th dimension is represented by a color scheme.  We show how to use the Mathematica library SpinShow to create a Mathematica animation.  Lastly, using the Mathematica Package, Dynamic Visualizer, we show how to create a movie of the plot which can be exported as a movie which can be viewed under windows or unix (avi format).

Initializations

<< Graphics`Graphics3D`
<< Graphics`Colors`
<< Statistics`DescriptiveStatistics`
<< "d:\\math\\2000\\mviz\\packages\\mviz.m"
envir = 
        Partition[ReadData["d:\\math\\2000\\mviz\\data\\environ.dat"], 
          4];
envir2 = Drop[Transpose[envir], -1] // Transpose;
ozone = Last[Transpose[envir]]^(1/3);   
quoz = Quartiles[ozone];
ind1 = 
        Select[Range[Length[ozone]], 
          ozone[[#]] < 
              quoz[[1]]  & ];
ind2 = 
        Select[Range[
            Length[ozone]], (ozone[[#]] ≥  
                  quoz[[1]]) && (ozone[[#]] < 
                  quoz[[2]]) & ];
ind3 = 
        Select[Range[
            Length[ozone]], (ozone[[#]] ≥  
                  quoz[[2]]) && (ozone[[#]] < 
                  quoz[[3]]) & ];
ind4 = 
        Select[Range[Length[ozone]], 
          ozone[[#]] ≥  
              quoz[[3]]  & ];

Choosing the Colors

This is my function to test out what a color looks like. Then we interactively choose the colors. The colors were chosen, as recommended by Cleveland (1994).  We choose 2 different saturations of purple and green which seem to show up well.

Plot[x^2, {x, 0, 2}, 
        PlotStyle -> {Thickness[0.02], 
            HLSColor[0.8, 0.85, 0.9]}];

Legend

PointLegend[colors_, titles_] := 
        Module[{g1, g2, K = Length[colors], 
            disksize = 0.12}, 
g1 = {RGBColor[1, 1, 1], 
              Line[{{0, 0.8}, {3, 0.8}}], 
              Line[{{0, K*1.1}, {3, K*1.1}}]}; 
g3 = 
            Transpose[{colors, Disk[#, disksize] & /@  
                  Transpose[{Array[-1 &, K], 
                      Range[K]}]}]; 
g2 = 
            MapThread[
              Text[#1, #2, {-1, 0}] &, {titles, 
                Transpose[{Array[0.5 &, K], 
                    Range[K]}]}]; 
Show[
            Graphics[{ AbsoluteThickness[5], g1, g2, g3}], 
            AspectRatio -> Automatic, ImageSize -> {300, 130}, 
            TextStyle -> {FontWeight -> "Bold", 
                FontSize -> 12}]];

g1 = 
        PointLegend[{HLSColor[0.6, 0.5, 0.9], HLSColor[0.6, 0.85, 0.9], 
            HLSColor[0.8, 0.85, 0.9], 
            HLSColor[0.8, 0.5, 
              0.9]}, {"1st quartile", "2nd quartile", "3rd quartile\
",  "4th quartile"}];

Export["d:\\math\\2000\\mviz\\eps\\scat3dlegend.eps", 
      g1, "EPS"]

PointCloud Display

psize = 8; 
    p1 = ScatterPlot3D[envir2[[ind1]],  BoxRatios -> {1, 1, 1},  
        PlotStyle -> {AbsolutePointSize[psize], 
            HLSColor[0.6, 0.5, 0.9]},  
        DisplayFunction -> Identity];
p2 = 
        ScatterPlot3D[envir2[[ind2]],  BoxRatios -> {1, 1, 1},  
          PlotStyle -> {AbsolutePointSize[psize], 
              HLSColor[0.6, 0.85, 0.9]},  
          DisplayFunction -> Identity];
p3 = 
        ScatterPlot3D[envir2[[ind3]],  BoxRatios -> {1, 1, 1},  
          PlotStyle -> {AbsolutePointSize[psize], 
              HLSColor[0.8, 0.85, 0.9]},  
          DisplayFunction -> Identity];
p4 = 
        ScatterPlot3D[envir2[[ind4]],  BoxRatios -> {1, 1, 1},  
          PlotStyle -> {AbsolutePointSize[psize], 
              HLSColor[0.8, 0.5, 0.9]},  
          DisplayFunction -> Identity];

p = 
        Show[{p1, p2, p3, p4}, 
          AxesLabel -> {"W", "R", "Tp"}, 
          DisplayFunction -> $DisplayFunction];

Export["d:\\math\\2000\\mviz\\eps\\scat3d.eps", 
      p, "EPSI"]

Animated Pointcloud

<< Graphics`Animation`

g = 
        Show[Graphics3D[{AbsolutePointSize[psize], HLSColor[0.6, 0.5, 0.9], 
              Point /@ envir2[[ind1] ], HLSColor[0.6, 0.85, 0.9], 
              Point /@ envir2[[ind2] ], HLSColor[0.8, 0.85, 0.9], 
              Point /@ envir2[[ind3] ], HLSColor[0.8, 0.5, 0.9], 
              Point /@ envir2[[ind4] ]}], 
          BoxRatios -> {1, 1, 1}];

SpinShow[p]

Dynamic Visualizer

<< DynamicVisualizer`
VisualizerPalettes[];
StartVisualizer[];

Visualize[g]

QuitVisualizer[]