balloonplot

balloonplot creates a balloon plot of a contingency table

Syntax

Description

A balloonplot is an alternative to bar plot for visualizing a large categorical data. It draws a graphical matrix of a contingency table, where each cell contains a dot whose size reflects the relative magnitude of the corresponding component. ballonplot is a bubble chart for contingency tables.

example

h =balloonplot(N) balloonplot with table input.

example

h =balloonplot(N, Name, Value) balloonplot with array input.

example

[h, Ntable] =balloonplot(___) balloonplot with original data matrix as input.

Examples

expand all

  • balloonplot with table input.
  • Load the Housetasks data (a contingency table containing the frequency of execution of 13 house tasks in the couple).

    N=[156	14	2	4;
    124	20	5	4;
    77	11	7	13;
    82	36	15	7;
    53	11	1	57;
    32	24	4	53;
    33	23	9	55;
    12	46	23	15;
    10	51	75	3;
    13	13	21	66;
    8	1	53	77;
    0	3	160	2;
    0	1	6	153];
    rowslab={'Laundry' 'Main-meal' 'Dinner' 'Breakfeast' 'Tidying' 'Dishes' ...
    'Shopping' 'Official' 'Driving' 'Finances' 'Insurance'...
    'Repairs' 'Holidays'};
    colslab={'Wife'	'Alternating'	'Husband'	'Jointly'};
    tableN=array2table(N,'VariableNames',colslab,'RowNames',rowslab);
    % In this case a table is supplied
    balloonplot(tableN);
    Click here for the graphical output of this example (link to Ro.S.A. website).

  • balloonplot with array input.
  • Load the Housetasks data (a contingency table containing the frequency of execution of 13 house tasks in the couple).

    N=[156	14	2	4;
    124	20	5	4;
    77	11	7	13;
    82	36	15	7;
    53	11	1	57;
    32	24	4	53;
    33	23	9	55;
    12	46	23	15;
    10	51	75	3;
    13	13	21	66;
    8	1	53	77;
    0	3	160	2;
    0	1	6	153];
    rowslab={'Laundry' 'Main-meal' 'Dinner' 'Breakfast' 'Tidying' 'Dishes' ...
    'Shopping' 'Official' 'Driving' 'Finances' 'Insurance'...
    'Repairs' 'Holidays'};
    colslab={'Wife'	'Alternating'	'Husband'	'Jointly'};
    tableN=array2table(N,'VariableNames',colslab,'RowNames',rowslab);
    % In this case row and columns labels are supplied through options Lr
    % and Lc
    balloonplot(N,'Lr',rowslab,'Lc',colslab);

  • balloonplot with original data matrix as input.
  • load smoke
    [h,Ntable]=balloonplot(smoke,'datamatrix',true);
    disp(Ntable)
                            None    Light    Medium    Heavy
                            ____    _____    ______    _____
    
        Senior_Managers       4       2         3        2  
        Junior_Managers       4       3         7        4  
        Senior_Employees     25      10        12        4  
        Junior_Employees     18      24        33       13  
        Secretaries          10       6         7        2  
    
    
    Click here for the graphical output of this example (link to Ro.S.A. website).

    Input Arguments

    expand all

    N — Contingency table (default) or n-by-2 input dataset. 2D Array or Table.

    2D array or table which contains the input contingency table (say of size I-by-J) or the original data matrix X.

    In this last case N=crosstab(X(:,1),X(:,2)). As default procedure assumes that the input is a contingency table.

    Data Types: single| double

    Name-Value Pair Arguments

    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    Example: 'ax',myaxes , 'datamatrix',true , 'Lr',{'a' 'b' 'c'} , 'Lc',{'c1' c2' 'c3' 'c4'}

    ax —displays the bubble chart in the target axes ax.axes object.

    If you do not specify the axes, MATLAB plots into the current axes, or it creates an Axes object if one does not exist.

    Example: 'ax',myaxes

    Data Types: Axes object

    datamatrix —Data matrix or contingency table.boolean.

    If datamatrix is true the first input argument N is forced to be interpreted as a data matrix, else if the input argument is false N is treated as a contingency table. The default value of datamatrix is false, that is the procedure automatically considers N as a contingency table (in array or table format). If datamatrix is true, N can be an array or a table of size n-by-2. Note that if N has more than two columns balloonplot is based on the first two columns of N (and a warning is produced).

    Example: 'datamatrix',true

    Data Types: logical

    Lr —Vector of row labels.cell.

    Cell containing the labels of the rows of the input contingency matrix N. This option is unnecessary if N is a table, because in this case Lr=N.Properties.RowNames;

    Example: 'Lr',{'a' 'b' 'c'}

    Data Types: cell array of strings

    Lc —Vector of column labels.cell.

    Cell containing the labels of the columns of the input contingency matrix N. This option is unnecessary if N is a table, because in this case Lc=N.Properties.VariableNames;

    Example: 'Lc',{'c1' c2' 'c3' 'c4'}

    Data Types: cell array of strings

    Output Arguments

    expand all

    h —returns the BubbleChart object. Use h to modify properties of the chart after creating it

    For a list of properties, see BubbleChart Properties.

    Ntable —$I$-by-$J$ contingency table. Table

    This is tha table which has been used to build the balloonplot.

    References

    This page has been automatically generated by our routine publishFS