Scatterplot Matrix
Example 1
Summary: Visualizes a scatterplot matrix to analyze the relationships between various fatty acid variables in an open data table, utilizing a Lower Triangular Matrix Format and adding fit lines for each pair of variables.
Code:
// Scatterplot Matrix
// Open data table
dt = Open("data_table.jmp");
// Scatterplot Matrix
Scatterplot Matrix(
Y(
:palmitic, :palmitoleic, :stearic,
:oleic, :linoleic, :linolenic,
:arachidic, :eicosenoic
),
Matrix Format( "Lower Triangular" ),
Fit Line( 0 )
);
Code Explanation:
- Open table.
- Create scatterplot matrix.
- Specify variables.
- Set matrix format.
- Add fit line.
Example 2
Summary: Creates a scatterplot matrix from a data table, setting Y and X variables, and configuring report settings with scale box 104.
Code:
Open("data_table.jmp");
sm = Scatterplot Matrix(
Y( :name, :age, :sex, :height, :weight ),
X( :name, :age, :sex, :height, :weight ),
SendToReport(
Dispatch( {}, "104", ScaleBox, {Min( 0 ), Max( 180 ), Inc( 20 ), Minor Ticks( 0 )} ),
Dispatch( {}, "1104", ScaleBox, {Min( 0 ), Max( 180 ), Inc( 20 ), Minor Ticks( 0 )} ),
)
);
Code Explanation:
- Open data table;
- Create scatterplot matrix.
- Set Y variables.
- Set X variables.
- Send report settings.
- Configure scale box 104.
- Set min to 0.
- Set max to 180.
- Set increment to 20.
- Disable minor ticks.
Example 3
Summary: Creates a scatterplot matrix with varying jitter values, enabling interactive exploration of relationships between age, sex, height, and weight.
Code:
dt = Open("data_table.jmp");
objNoJitter = dt << Scatterplot Matrix(
Y( :age, :sex, :height, :weight ),
Matrix Format( "Lower Triangular" ),
Fit Line( 1 ),
Density Ellipses( 1 ),
Shaded Ellipses( 1 )
);
For Each( {JitterValue}, {"None", "Auto", "Random Uniform", "Random Normal", "Packed", "Centered Grid", "Positive Grid", "Density Random"},
objWithJitter = dt << Scatterplot Matrix(
Y( :age, :sex, :height, :weight ),
Matrix Format( "Lower Triangular" ),
Points Jittered( JitterValue ),
Fit Line( 1 ),
Density Ellipses( 1 ),
Shaded Ellipses( 1 ),
)
);
Code Explanation:
- Open data table.
- Create scatterplot matrix without jitter.
- Set matrix format to lower triangular.
- Add fit lines to plots.
- Enable density ellipses.
- Enable shaded ellipses.
- Loop through jitter values.
- Create scatterplot matrix for each jitter value.
- Set matrix format to lower triangular.
- Apply current jitter value to points.
Example 4
Summary: Creates a scatterplot matrix from a data table, utilizing default naming conventions.
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Scatterplot Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ) );
Code Explanation:
- Set default name scope.
- Open data table;
- Create scatterplot matrix.
Example 5
Summary: Creates a scatterplot matrix with lower triangular format, using 'height' as the Y variable and 'weight' as the X variable, and configures the row legend for 'age'.
Code:
dt = Open("data_table.jmp");
obj = Scatterplot Matrix(
Y( :height ),
X( :weight ),
Matrix Format( "Lower Triangular" ),
SendToReport(
Dispatch( {}, "ScatterPlot Matrix Plot", FrameBox,
{Row Legend(
age,
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
);
Code Explanation:
- Open data table.
- Create scatterplot matrix.
- Set Y variable to height.
- Set X variable to weight.
- Format matrix as lower triangular.
- Send report to dispatch.
- Configure row legend for age.
- Set color theme to JMP Default.
- Disable marker usage.
- Disable marker theme.
Example 6
Summary: Creates and customizes a scatterplot matrix, filtering data by age 11 and generating reports from the filtered dataset.
Code:
dt = Open("data_table.jmp");
obj = Scatterplot Matrix(
Y( :age, :sex, :height, :weight ),
Matrix Format( "Lower Triangular" ),
Ellipse Color( 3 ),
Local Data Filter( Add Filter( columns( :age ), Where( :age == 11 ) ), Mode( Select( 0 ), Show( 1 ), Include( 1 ) ) ),
);
obj << Automatic Recalc( 1 );
dt << Select Where( :idnum >= 600 );
dt << Exclude();
rpt = Report( obj );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Scatterplot Matrix(
Y( :age, :sex, :height, :weight ),
Matrix Format( "Lower Triangular" ),
Ellipse Color( 3 ),
Local Data Filter( Add Filter( columns( :age ), Where( :age == 11 ) ), Mode( Select( 0 ), Show( 1 ), Include( 1 ) ) ),
);
obj << Automatic Recalc( 0 );
dt << Select Where( :idnum >= 600 );
dt << Exclude();
rpt = Report( obj );
Code Explanation:
- Open data table;
- Create scatterplot matrix.
- Set matrix format to lower triangular.
- Set ellipse color to blue.
- Add local data filter for age 11.
- Enable automatic recalculation.
- Select rows where idnum is 600 or higher.
- Exclude selected rows.
- Generate report from scatterplot.
- Close dataset without saving.
- Reopen data_table dataset
- Recreate scatterplot matrix.
- Disable automatic recalculation.
- Select rows where idnum is 600 or higher.
- Exclude selected rows.
- Generate report from scatterplot.
Example 7
Summary: Creates and customizes a scatterplot matrix to visualize relationships between age, sex, height, and weight data, with interactive features for density ellipses and shaded regions.
Code:
dt = Open("data_table.jmp");
obj = Scatterplot Matrix(
Y( :age, :sex, :height, :weight ),
Matrix Format( "Lower Triangular" ),
Fit Line( 1 ),
Density Ellipses( 1 ),
Shaded Ellipses( 1 ),
Ellipse Color( 3 ),
Nonpar Density( 1 ),
Ellipses Coverage( 0.9 ),
SendToReport( Dispatch( {}, FrameBox, {Frame Size( 46, 37 )} ) )
);
:Age << Set Property( "Missing Value Codes", 999 );
:Age << Set Values( {999, 999, 999} );
obj2 = obj << Redo Analysis;
rpt = obj2 << Report;
expr = rpt[FrameBox( 1 )] << Get Journal;
p = "x(.,.,.,";
ans = Pat Match( expr, p );
Code Explanation:
- Open data_table data
- Create scatterplot matrix.
- Set matrix format to lower triangular.
- Fit lines to plots.
- Add density ellipses.
- Shade ellipses.
- Set ellipse color to blue.
- Enable nonparametric density.
- Set ellipses coverage to 90%.
- Adjust frame size to 46x37.
- Set missing value code for Age to 999.
- Replace Age values with 999.
- Redo analysis with updated data.
- Generate report from analysis.
- Extract journal from first frame.
- Define pattern to search for.
- Search journal for pattern.
Example 8
Summary: Creates a scatterplot matrix to visualize relationships between height and weight, while controlling for age and sex.
Code:
dt = Open("data_table.jmp");
Scatterplot Matrix(
Y( :height, Transform Column( "height*height", Formula( :height * :height ) ) ),
X( :weight ),
Density Ellipses( 1 ),
Group By( :age ),
By( :sex )
);
Code Explanation:
- Open data table;
- Create scatterplot matrix.
- Add height variable.
- Transform height to height squared.
- Add weight variable.
- Enable density ellipses.
- Group by age.
- Apply by sex.
Example 9
Summary: Creates a scatterplot matrix to visualize relationships between height, weight, and age, with density ellipses at 1 level, grouped by sex.
Code:
dt = Open("data_table.jmp");
dt = Open("data_table.jmp");
Scatterplot Matrix(
Y( :height, Transform Column( "height*height", Formula( :height * :height ) ) ),
X( :weight ),
Density Ellipses( 1 ),
Group By( :age ),
By( :sex )
);
Code Explanation:
- Open data table;
- Open data table;
- Create Scatterplot Matrix.
- Set Y variables: height, height*height.
- Transform height to height*height.
- Set X variable: weight.
- Add Density Ellipses at 1 level.
- Group data by age.
- Use sex for By grouping.
- Display the graph.
Example 10
Summary: Creates and customizes scatterplot matrices with density ellipses for exploratory data analysis, generating two report objects with varying ellipse coverage settings.
Code:
dt = Open("data_table.jmp");
obj = Scatterplot Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Group( :Species ) );
obj << Density Ellipses( 1 );
obj << Ellipses Coverage( 0.95 );
robj = obj << report;
obj1 = Scatterplot Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Group( :Species ) );
obj1 << Density Ellipses( 1 );
obj1 << Ellipses Coverage( 0.99 );
robj1 = obj1 << report;
Code Explanation:
- Open data table;
- Create scatterplot matrix.
- Add density ellipses.
- Set ellipse coverage to 95%.
- Generate report object.
- Create second scatterplot matrix.
- Add density ellipses.
- Set ellipse coverage to 99%.
- Generate second report object.
Example 11
Summary: Creates a scatterplot matrix with jittered points, generates a report object, and extracts the journal from the first frame box.
Code:
dt = Open("data_table.jmp");
obj = Scatterplot Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ) );
obj << Points Jittered( 0 );
rep = Report( obj );
jrn = rep[FrameBox( 1 )] << get journal;
Code Explanation:
- Open data table;
- Create scatterplot matrix.
- Set points jittered off.
- Generate report object.
- Extract first frame box.
- Get journal from frame.
Example 12
Summary: Creates a scatterplot matrix with multiple variables, formatting the output as a lower triangular matrix and adding fit lines to each plot.
Code:
dt = Open("data_table.jmp");
Scatterplot Matrix(
Y( :Age, :Weight, :Cholesterol ),
X( :Triglycerides, :HDL, :LDL, :Height ),
Matrix Format( "Lower Triangular" ),
Fit Line( 1 )
);
Code Explanation:
- Open data table;
- Create Scatterplot Matrix.
- Set Y variables: Age, Weight, Cholesterol.
- Set X variables: Triglycerides, HDL, LDL, Height.
- Format matrix as Lower Triangular.
- Add Fit Line to plots.
Example 13
Summary: Creates and analyzes a scatterplot matrix to visualize relationships between height and age, with jittering applied for improved visualization.
Code:
dt = Open("data_table.jmp");
spm = Scatterplot Matrix( Y( :height, :age ), Points Jittered( 0 ) );
rpt = Report( spm );
jrn = rpt << get journal;
xexp = dt:height << get values;
yexp = (dt:age << get values) - Min( dt:age << get values );
spm << close window;
spm = Scatterplot Matrix( Y( :height, :age ), Points Jittered( 1 ) );
rpt = Report( spm );
jrn = rpt << get journal;
xexp = dt:height << get values;
yexp = (dt:age << get values) - Min( dt:age << get values );
Close( dt, No Save );
data_path = "/tests/s/";
Code Explanation:
- Open data table.
- Create scatterplot matrix.
- Retrieve report object.
- Extract journal from report.
- Get height values.
- Adjust age values.
- Close scatterplot window.
- Recreate scatterplot matrix with jitter.
- Retrieve updated report object.
- Extract new journal from report.
Example 14
Summary: Creates and analyzes a scatterplot matrix to visualize relationships between height and age, utilizing JMP's reporting capabilities.
Code:
dt = Open("data_table.jmp");
spm = Scatterplot Matrix( Y( :height, :age ), Points Jittered( 0 ) );
rpt = Report( spm );
jrn = rpt << get journal;
xexp = dt:height << get values;
yexp = (dt:age << get values) - Min( dt:age << get values );
spm << close window;
spm = Scatterplot Matrix( Y( :height, :age ), Points Jittered( 1 ) );
rpt = Report( spm );
jrn = rpt << get journal;
xexp = dt:height << get values;
yexp = (dt:age << get values) - Min( dt:age << get values );
Code Explanation:
- Open data table.
- Create scatterplot matrix.
- Retrieve report object.
- Extract journal from report.
- Get height values.
- Normalize age values.
- Close scatterplot matrix.
- Recreate scatterplot matrix.
- Retrieve updated report object.
- Extract updated journal from report.
Example 15
Summary: Creates a scatterplot matrix with density ellipses and group filtering for 'setosa' species, utilizing JMP's Scatterplot Matrix platform.
Code:
dt = Open("data_table.jmp");
sm = dt << Scatterplot Matrix(
Y( :Sepal width ),
X( :Sepal length ),
Matrix Format( "Upper Triangular" ),
Density Ellipses( 1 ),
Ellipse Color( 3 ),
Fit Line( 0 ),
Group By( :Species ),
Lock Scales( 1 )
);
rp = Report( sm );
ymin = rp[AxisBox( 1 )] << get min;
ymax = rp[AxisBox( 1 )] << get max;
xmin = rp[AxisBox( 2 )] << get min;
xmax = rp[AxisBox( 2 )] << get max;
df = dt << Data Filter( Add Filter( columns( :Species ), Where( :Species == "setosa" ) ), Mode( Select( 0 ), Show( 1 ), Include( 1 ) ) );
rp = Report( sm );
df << Close;
dt << Clear Row States;
sm = dt << Scatterplot Matrix(
Y( :Sepal width ),
X( :Sepal length ),
Matrix Format( "Upper Triangular" ),
Density Ellipses( 1 ),
Ellipse Color( 3 ),
Fit Line( 0 ),
Group By( :Species ),
Lock Scales( 1 )
);
rp = Report( sm );
ymin = rp[AxisBox( 1 )] << get min;
ymax = rp[AxisBox( 1 )] << get max;
xmin = rp[AxisBox( 2 )] << get min;
xmax = rp[AxisBox( 2 )] << get max;
sm << Local Data Filter( Add Filter( columns( :Species ), Where( :Species == "setosa" ) ), Mode( Select( 0 ), Show( 1 ), Include( 1 ) ) );
rp = Report( sm );
Code Explanation:
- Open data table;
- Create scatterplot matrix.
- Set Y variable.
- Set X variable.
- Configure matrix format.
- Add density ellipses.
- Set ellipse color.
- Disable fit lines.
- Group by species.
- Lock scales.
Example 16
Summary: Creates a scatterplot matrix for Sepal width and length, filtering data by species, and visualizing axis ranges.
Code:
dt = Open("data_table.jmp");
sm = Scatterplot Matrix( Y( 2 :: 7 ), Lock Scales( 1 ) );
rp = Report( sm );
min = rp[AxisBox( 2 )] << get min;
max = rp[AxisBox( 2 )] << get max;
dt << Select Where( :Ether > 0 );
dt << Exclude;
rp = Report( sm );
Close( dt, No Save );
dt = Open("data_table.jmp");
sm = dt << Scatterplot Matrix(
Y( :Sepal width ),
X( :Sepal length ),
Matrix Format( "Upper Triangular" ),
Density Ellipses( 1 ),
Ellipse Color( 3 ),
Fit Line( 0 ),
Group By( :Species ),
Lock Scales( 1 )
);
rp = Report( sm );
ymin = rp[AxisBox( 1 )] << get min;
ymax = rp[AxisBox( 1 )] << get max;
xmin = rp[AxisBox( 2 )] << get min;
xmax = rp[AxisBox( 2 )] << get max;
df = dt << Data Filter( Add Filter( columns( :Species ), Where( :Species == "setosa" ) ), Mode( Select( 0 ), Show( 1 ), Include( 1 ) ) );
rp = Report( sm );
df << Close;
dt << Clear Row States;
sm = dt << Scatterplot Matrix(
Y( :Sepal width ),
X( :Sepal length ),
Matrix Format( "Upper Triangular" ),
Density Ellipses( 1 ),
Ellipse Color( 3 ),
Fit Line( 0 ),
Group By( :Species ),
Lock Scales( 1 )
);
rp = Report( sm );
ymin = rp[AxisBox( 1 )] << get min;
ymax = rp[AxisBox( 1 )] << get max;
xmin = rp[AxisBox( 2 )] << get min;
xmax = rp[AxisBox( 2 )] << get max;
sm << Local Data Filter( Add Filter( columns( :Species ), Where( :Species == "setosa" ) ), Mode( Select( 0 ), Show( 1 ), Include( 1 ) ) );
rp = Report( sm );
Code Explanation:
- Open data table.
- Create scatterplot matrix.
- Get axis min and max.
- Select rows where Ether > 0.
- Exclude selected rows.
- Close data table without saving.
- Open data table.
- Create scatterplot matrix for Sepal width and length.
- Get axis min and max.
- Apply data filter for setosa species.
Example 17
Summary: Creates a scatterplot matrix with fit lines, selecting all rows and deleting them from the data table.
Code:
dt = Open("data_table.jmp");
obj = dt << Scatterplot Matrix( Y( :age, :height, :weight ), X( :sex ), Fit Line( 0 ), Automatic Recalc( 0 ) );
dt << Select Rows( 1 :: N Row( dt ) );
dt << Delete Rows;
Code Explanation:
- Open data table.
- Create scatterplot matrix.
- Set Y variables.
- Set X variable.
- Add fit line option.
- Disable automatic recalculation.
- Select all rows.
- Delete selected rows.
Example 18
Summary: Creates a scatterplot matrix to visualize relationships between height and weight, with a lower triangular matrix format and customized row legend for age.
Code:
dt = Open("data_table.jmp");
obj = dt << Scatterplot Matrix(
Y( :height ),
X( :weight ),
Matrix Format( "Lower Triangular" ),
SendToReport(
Dispatch( {}, "ScatterPlot Matrix Plot", FrameBox,
{Row Legend(
age,
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
);
rpt = obj << report;
Close( dt, NoSave );
cert levels = {levels( "Violent Rate" ), levels( "Violent Rate" )};
Code Explanation:
- Open data table;
- Create scatterplot matrix.
- Set Y variable to height.
- Set X variable to weight.
- Format matrix as lower triangular.
- Send report to object.
- Dispatch to frame box.
- Configure row legend for age.
- Set color theme to JMP Default.
- Close dataset without saving.
Example 19
Summary: Creates a scatterplot matrix from a data table, with the Y variable set to height and X variable set to weight, formatted as a lower triangular matrix, and configured with a row legend for age.
Code:
Open("data_table.jmp");
obj = Scatterplot Matrix(
Y( :height ),
X( :weight ),
Matrix Format( "Lower Triangular" ),
SendToReport(
Dispatch( {}, "ScatterPlot Matrix Plot", FrameBox,
{Row Legend(
age,
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
);
rpt = obj << report;
Code Explanation:
- Open data table.
- Create scatterplot matrix.
- Set Y variable to height.
- Set X variable to weight.
- Format matrix as lower triangular.
- Send report to script.
- Dispatch to scatterplot matrix plot.
- Configure row legend for age.
- Set color theme to default.
- Retrieve report object.