Create a scatter plot matrix in Scilab

Abstract

In this page, we present a function to create a scatter plot matrix in Scilab.

Introduction

According to NIST [1], "given a set of variables X1, X2, ... , Xk, the scatter plot matrix contains all the pairwise scatter plots of the variables on a single page in a matrix format. That is, if there are k variables, the scatter plot matrix will have k rows and k columns and the ith row and jth column of this matrix is a plot of Xi versus Xj."

This feature is available from the "plotmatrix" function in Stixbox, v2.2. To install it, please use

atomsInstall('stixbox')

and restart Scilab.

The scripts are also available in attachement :

Scatter plot matrix

The function scattermatrix creates a scatter plot matrix. It has the calling sequence:

scattermatrix(x)

where x is a n-by-ninput matrix of doubles. Here, ninput is the number of input parameters and n is the number of experiments.

Here is the simplest example of scattermatrix. We have a model with 3 inputs and 3 outputs. We are interested in the scatter plot matrix of the outputs y1, y2, y3.

    m=1000;
    x1=grand(m,1,"def");
    x2=grand(m,1,"def");
    x3=grand(m,1,"def");
    y1=2*x1.*x2+x3;
    y2=-3*x1+x2.^2-2*x3;
    y3=sin(x1)-3*x2+3*x3;
    y=[y1,y2,y3];
    //
    ylabels=["Y1","Y2","Y3"];
    // No labels
    scattermatrix(y);

scattermatrix-0.png

It is straightforward to add labels:

    // With labels
    scattermatrix(y,"xlabels",ylabels);

scattermatrix-1.png

We can also replace the empty diagonal with an histogram.

    // With the histogram
    scattermatrix(y,"histogram",%t);

scatterHisto.png

Scatter matrix X vs Y

The function scattermatrixXY plots the dependencies between Y and X in a model.

The script:

    m=1000;
    x1=grand(m,1,"def");
    x2=grand(m,1,"def");
    x3=grand(m,1,"def");
    y1=2*x1.*x2+x3;
    y2=-3*x1+x2.^2-2*x3;
    y3=sin(x1)-3*x2+3*x3;
    x=[x1,x2,x3];
    y=[y1,y2,y3];
    //
    xlabels=["X1","X2","X3"];
    ylabels=["Y1","Y2","Y3"];
    // No labels
    scattermatrixXY(x,y);

produces:

scattermatrixXY-0.png

This is perhaps clearer with labels.

    // With labels
    scattermatrixXY(x,y,"xlabels",xlabels,"ylabels",ylabels);

scattermatrixXY-1.png

We can customize various settings, including the labels, the dot symbol and the size of the point.

scattermatrixXY-2.png

scattermatrixXY-3.png

scattermatrixXY-4.png

scattermatrixXY-5.png

References



Author: Michaƫl Baudin, 2013

public: howto/scatterplotmatrix (last edited 2017-12-11 14:27:02 by 194)