SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

DOT MATRIX PLOT
DOT MATRIX PROPORTION PLOT

Name:
    DOT MATRIX PLOT
    DOT MATRIX PROPORTION PLOT
Type:
    Graphics Command
Purpose:
    Generates a dot matrix plot.
Description:
    The dot matrix plot uses a grid of dots to display the counts of the cross tabulation of two categorial variables. We will refer to the first categorical variable as the "group" variable and the second categorical variable as the "category" variable.

    The group variable is used to define a grid of subplots within the plot frame. For example, if there are nine distinct levels in the group variable, a grid of three rows and three columns will be defined (the ordering of the levels in the group variable is from left to right horizontally and from bottom to top vertically. The grid is filled in row order (i.e., the first subplot is the bottom row and the left most column, the second subplot is the bottom row and the second column from the left and so on).

    Within each group, the counts are obtained for each level of the categorical variable.

    For the first variation of this plot, each level of the category will generate n filled circles (the actual symbol plotted is user settable) where n is the count for that level. The ordering is from left to right and top to bottom in row order. This variation is most useful when the number of groups and categories is relatively modest and the counts are relatively small.

    For the second variation of this plot, for each subplot a fixed number of rows and columns are specified (the default is 10 rows and 10 columns). Instead of plotting the raw counts, the proportion for each level of the category is computed. The number of dots generated for a level i of a category is then

      INT(nrow*ncol*(count(i)/ntotal) + 0.5)

    with nrow, ncol, count(i) and ntotal denoting the number of rows in the subplot, the number of columns in the subpplot, the count for level i of the category variable and the total count for all levels of the category variable, respectively. This version of the plot is also known as a waffle plot. It may be a better choice when the number of counts is relatively large.

Syntax 1:
    DOT MATRIX PLOT <group> <cat>             <SUBSET/EXCEPT/FOR qualification>
    where <group> is the group-id variable;
                <cat> is the category-id variable;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax performs a cross tabulation to obtain the counts for the group and category combinations.

Syntax 2:
    DOT MATRIX PLOT <count> <group> <cat>
                            <SUBSET/EXCEPT/FOR qualification>
    where <count> is a variable containing the counts for each group/category combination;
                <group> is the group-id variable;
                <cat> is the category-id variable;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax is used for the case where the counts have already been tabulated.

Syntax 3:
    DOT MATRIX PROPORTION PLOT <group> <cat>
                            <SUBSET/EXCEPT/FOR qualification>
    where <group> is the group-id variable;
                <cat> is the category-id variable;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax performs a cross tabulation to obtain the counts for the group and category combinations. In this case, the number of dots for a specific level of the category is based on the proportion of the total count for that level and the total number of dots is fixed.

Syntax 4:
    DOT MATRIX PLOT <count> <group> <cat>
                            <SUBSET/EXCEPT/FOR qualification>
    where <count> is a variable containing the counts for each group/category combination;
                <group> is the group-id variable;
                <cat> is the category-id variable;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax is used for the case where the counts have already been tabulated. In this case, the number of dots for a specific level of the category is based on the proportion of the total count for that level and the total number of dots is fixed.

Examples:
    DOT MATRIX PLOT GROUP CATEGORY
    DOT MATRIX PLOT COUNTS GROUP CATEGORY
    DOT MATRIX PLOT GROUP CATEGORY SUBSET CATEGORY > 2
Note:
    For Syntax 1 and Syntax 2, the number of group columns can be specified with the command

      SET DOT MATRIX PLOT NUMBER OF GROUP COLUMNS <value>

    For Syntax 1 and Syntax 2, the number of category columns can be specified with the command

      SET DOT MATRIX PLOT NUMBER OF CATEGORY COLUMNS <value>

    If these commands are not specified, Dataplot will determine a value based on the number of groups and the maximum count of the groups.

Note:
    For Syntax 3 and Syntax 4, the number of rows and columns for a given subplot can be specified with the commands

      SET DOT MATRIX PLOT HORIZONTAL GRID VALUE <value>
      SET DOT MATRIX PLOT VERTICAL GRID VALUE <value>

    The default is 10 rows and 10 columns.

    Due to rounding of the proportions, the number of dots generated may be slightly less than or slightly greater than the requested number. For example, if there are three levels for a category and each level has an equal count, this will result in 99 dots (assuming a 10x10 grid) as each level has a proportion of 0.33.

Default:
    None
Synonyms:
    WAFFLE PLOT is a synonym for DOT MATRIX PROPORTION PLOT
Related Commands: Applications:
    Presentation Graphics
Implementation Date:
    2025/11
Program 1:
     
    . Step 1:   Read the data
    .
    skip 25
    read alarm.dat inst src
    skip 0
    .
    . Step 2:   Set some plot control
    .
    character circle all
    character fill on all
    character hw 1.0 0.75 all
    character color blue red cyan black green magenta
    .
    limits 1 4
    major tic mark number 4
    minor tic mark number 0
    tic mark offset units data
    tic mark offset 0.8 0.8
    .
    . Step 3:   Generate the plot
    .
    title Sample Dot Matrix Plot
    dot matrix plot inst src
    .
    .           Add labels for grid points
    .
    let ncol = 4
    let ninst = unique inst
    let ival = mod(ninst,ncol)
    let nrow = int(ninst/ncol)
    if ival > 0
       let nrow = nrow + 1
    end of if
    .
    justification center
    height = 1.7
    let irow = 1
    let icol = 0
    let icnt = 0
    loop for k = 1 1 ninst
        let icnt = icnt + 1
        let icol = icol + 1
        if icol > ncol
           let icol = 1
           let irow = irow + 1
        end of if
        let xcoor = icol
        let ycoor = irow + 0.55
        movedd xcoor ycoor
        text Instrument ^k
    end of loop
    .
    height 1.5
    justification left
    move 87 88
    text Blue:    Source 1
    move 87 85
    text Red:     Source 2
    move 87 82
    text Cyan:    Source 3
    move 87 79
    text Black:   Source 4
    move 87 76
    text Green:   Source 5
    move 87 73
    text Magenta: Source 6
    
    .
    . Step 4:   Generate the proportion version of the plot
    .
    title Sample Dot Matrix Proportion Plot
    capture dot.out
    cross tabulate inst src
    end of capture
    dot matrix proportion plot inst src
    .
    .           Add labels for grid points
    .
    let ncol = 4
    let ninst = unique inst
    let ival = mod(ninst,ncol)
    let nrow = int(ninst/ncol)
    if ival > 0
       let nrow = nrow + 1
    end of if
    .
    justification center
    height = 1.7
    let irow = 1
    let icol = 0
    let icnt = 0
    loop for k = 1 1 ninst
        let icnt = icnt + 1
        let icol = icol + 1
        if icol > ncol
           let icol = 1
           let irow = irow + 1
        end of if
        let xcoor = icol
        let ycoor = irow + 0.52
        movedd xcoor ycoor
        text Instrument ^k
        write1 junk.out k irow icol xcoor ycoor
    end of loop
    .
    height 1.5
    justification left
    move 87 88
    text Blue:    Source 1
    move 87 85
    text Red:     Source 2
    move 87 82
    text Cyan:    Source 3
    move 87 79
    text Black:   Source 4
    move 87 76
    text Green:   Source 5
    move 87 73
    text Magenta: Source 6
        
Program 2:
     
    . Step 1:   Read the data
    .
    read y haircolo eyecolor
      5  1  1
     29  2  1
     14  3  1
     16  4  1
     15  1  2
     54  2  2
     14  3  2
     10  4  2
     20  1  3
     84  2  3
     17  3  3
     94  4  3
     68  1  4
    119  2  4
     26  3  4
      7  4  4
    end of data
    .
    let string shair1 = Black
    let string shair2 = Brown
    let string shair3 = Red
    let string shair4 = Blond
    .
    let string seye1  = Green
    let string seye2  = Hazel
    let string seye3  = Blue
    let string seye4  = Brown
    .
    . Step 2:   Set some plot control
    .
    character circle all
    character fill on all
    character hw 1.0 0.75 all
    character color blue red black magenta
    .
    limits 1 2
    major tic mark number 2
    minor tic mark number 0
    tic mark offset units data
    tic mark offset 0.8 0.8
    .
    . Step 3:   Generate the plot
    .
    title Sample Dot Matrix Plot from Precomuted Counts
    dot matrix plot y haircolo eyecolor
    .
    .           Add labels for grid points
    .
    let ncol = 2
    let nrow = 2
    let nhair = unique haircolo
    .
    justification center
    height = 1.7
    let irow = 1
    let icol = 0
    let icnt = 0
    loop for k = 1 1 nhair
        let icnt = icnt + 1
        let icol = icol + 1
        if icol > ncol
           let icol = 1
           let irow = irow + 1
        end of if
        let xcoor = icol
        let ycoor = irow + 0.55
        movedd xcoor ycoor
        text ^shair^k
    end of loop
    .
    height 1.5
    justification left
    move 87 88
    text Blue:    ^seye1
    move 87 85
    text Red:     ^seye2
    move 87 82
    text Black:   ^seye3
    move 87 79
    text Magenta: ^seye4
        
    .
    . Step 4:   Generate the proportion version of the plot
    .
    title Sample Dot Matrix Proportion Plot
    dot matrix proportion plot y haircolo eyecolor
    .
    .           Add labels for grid points
    .
    justification center
    height = 1.7
    let irow = 1
    let icol = 0
    let icnt = 0
    loop for k = 1 1 nhair
        let icnt = icnt + 1
        let icol = icol + 1
        if icol > ncol
           let icol = 1
           let irow = irow + 1
        end of if
        let xcoor = icol
        let ycoor = irow + 0.55
        movedd xcoor ycoor
        text ^shair^k
    end of loop
    .
    height 1.5
    justification left
    move 87 88
    text Blue:    ^seye1
    move 87 85
    text Red:     ^seye2
    move 87 82
    text Black:   ^seye3
    move 87 79
    text Magenta: ^seye4
        
Date created: 12/02/2025
Last updated: 12/02/2025

Please email comments on this WWW page to [email protected].