Page 162 - Computational Statistics Handbook with MATLAB
P. 162

Chapter 5: Exploratory Data Analysis                            149


                             The results are shown in Figure 5.26. Several argument options are available
                             for the plotmatrix function. If the first two arguments are matrices, then
                             MATLAB plots one column versus the other column. In our example, we use
                             a single matrix argument, and MATLAB creates scatterplots of all possible
                             pairs of variables. Histograms of each variable or column are shown along
                             the diagonal of the scatterplot matrix. Optional output arguments allow one
                             to add a title or change the plot as shown in the following MATLAB com-
                             mands. Here we replace the histograms with text that identifies the variable
                             names and display the result in Figure 5.27.
                                % Create the labels as a cell array of strings.
                                labs = {'Sepal Length','Sepal Width',...
                                      'Petal Length', 'Petal Width'};
                                [H,ax,bigax,P] = plotmatrix(virginica);
                                axes(bigax)
                                title('Virginica')
                                % Delete the histograms.
                                delete(P)
                                %Put the labels in - the positions might have
                                % to be adjusted depending on the text.
                                for i = 1:4
                                   txtax = axes('Position',get(ax(i,i),'Position'),...
                                      'units','normalized');
                                   text(.1, .5,labs{i})
                                   set(txtax,'xtick',[],'ytick',[],...
                                      'xgrid','off','ygrid','off','box','on')
                                end





                                         ssuurr fafa
                                           rf
                                       s
                                     dd
                                      Iso
                                             cceess
                             Sl
                             SSll
                             Sli ii iccesanand  dIso IsoIso  suur  afac  cees  s
                                es
                                es
                               ccesanan
                             If we have a function defined over a volume,  f xy z,,(  )  , then we can view it
                             using the MATLAB slice function or the isosurface function (available
                             in MATLAB 5.3 and higher). This situation could arise in cases where we
                             have a probability density function defined over a volume. The slice capa-
                             bility allows us to view the distribution of our data on slices through a vol-
                             ume. The isosurface function allows us to view 3-D contours through our
                             volume. These are illustrated in the following examples.
                             Example 5.18
                                                                    (
                                                                     ,,
                             To illustrate the slice function, we need  f xy z)   values that are defined
                             over a 3-D grid or volume. We will use a trivariate normal distribution cen-
                             tered at the origin with covariance equal to the identity matrix. The following
                             MATLAB code displays slices through the x =  0  , y =  0  , and z =  0   planes,
                             and the resulting display is shown in Figure 5.28. A standard normal bivari-
                            © 2002 by Chapman & Hall/CRC
   157   158   159   160   161   162   163   164   165   166   167