Count number instead of dots in scatterplot matrix of binary dataHi all,
I have a dataset with 40 columns and 300+ rows.
For every column (= an event name) the values are binary, meaning yes/no attendance of the event for each row.
I am interested to see if there is a correlation in attendance between the different events/columns.
I managed to visualize this with a scatterplot matrix.
I adjusted the axes for the matrix to only show values that have value 1 for both columns/events, as I am only interested in cases where both events of the scatterplot matrix were attended by a row.
My scatterplot matrix looks like below image, but a lot bigger.
Every dot is a row for which both events/columns of the scatterplot matrix have a value of 1.
But it is very difficult to count the dots in the many different possible combination of events/columns (= the individual boxes/subplots of the scatterplot matrix).
My question is: is it possible to change the dots in the individual boxes into the actual count number for each individual box?

Synthax for the scatterplot matrix looks like below
Note that for readability I dont list all the event names, and only the scalebox synthax for 2 columns/events.
This is highlighted in red text.
:
Scatterplot Matrix(
Y(
:Here a long list with the ~40 column/event names,
Matrix Format( "Lower Triangular" ),
SendToReport(
Dispatch(
{},
"140",
ScaleBox,
{Min( 0.5 ), Max( 1.5 ), Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"139",
ScaleBox,
{Format( "Best", 15 ), Min( 0.5 ), Max( 1.5 ), Inc( 1 ),
Minor Ticks( 0 )}
),
Followed by 38 more similar code segments for the other 38 columns/events.
Data Exploration and VisualizationRe: Count number instead of dots in scatterplot matrix of binary dataHere is a script that creates a new data table with the counts

Which gives you your scatter plot counts, and it then creates a cell plot which gives you a color map of the values.

Names Default to Here( 1 );
dt = Current Data Table();
dtCounts = New Table( "Counts", add rows( 40 ) );
dtCounts << delete columns( :column 1 );
For( i = 1, i <= 40, i++,
dtCounts << New Column( "c" || Char( i ), set each value( . ) )
);
For( i = 1, i <= 40, i++,
For( k = i, k <= 40, k++,
theCount = Length( dt << get rows where( As Column( dt, i ) == 1 & As Column( dt, k ) == 1 ) );
dtCounts[i, k] = theCount;
dtCounts[k, i] = theCount;
)
);
dtCounts << New Column( "The Columns", character, set each value( "c" || Char( Row() ) ) );
dtCounts << move selected columns( :The Columns, to first );
dtCounts << Cell Plot(
Scale Uniformly( 1 ),
Center at zero( 0 ),
Y(
:c1, :c2, :c3, :c4, :c5, :c6, :c7, :c8, :c9, :c10, :c11, :c12, :c13, :c14, :c15, :c16, :c17, :c18,
:c19, :c20, :c21, :c22, :c23, :c24, :c25, :c26, :c27, :c28, :c29, :c30, :c31, :c32, :c33, :c34, :c35,
:c36, :c37, :c38, :c39, :c40
),
Label( :The Columns ),
Legend( 1 ),
SendToReport(
Dispatch( {}, "Cell Plot Report", FrameBox, {Frame Size( 79, 23 )} ),
Dispatch( {}, "", Lineup Box( 2 ), {Spacing( 1 )} )
)
);
Re: Count number instead of dots in scatterplot matrix of binary data Many thanks for this!
the new data table with counts makes sense when randomly checking several values.
But somehow the table and corresponding figure stop after column 16, see below.
I see nothing out of the ordinary in the script that I simply copy&pasted (i.e. no extra commas or something that I accidently put in there).
Any suggestion why this could be?

Re: Count number instead of dots in scatterplot matrix of binary dataWould it be possible to attach a copy of your data? If necessary, you can Anonymize the data before you attach it.
Also, your display has 41 columns, and the code assumes 40 columns.