Hi,
I attach a script which generates a small data table with an attached JSL script called "Grid of Color-Coded Scatter Plots", which if you run it should produce a Graph Builder output showing a (2x2) grid of scatter plots in each of which all the points are given different colors and/or symbols.
The problem I have is that I'm trying to write a script that will allow me to exchange the variables in such a chart for a different set of columns within the same data set, and/or the number of variables being charted on either or both of the X and Y axes (e.g. the example currently shows a (2x2) grid, but I might want to change that into a (3x2) grid by adding a third X data column onto the X axis).
I know how to apply the "<< Add Variable" and "<< Remove Variable" properties to gb[GraphBuilderBox(1)], where gb is the Graph Builder object, to swap one set of variables in the chart for another set. What I haven't been able to work out is how to modify the corresponding Elements statements. There's an example in the Scripting Index which applies to the GraphBuilderBox display box, but the "<< Add Element" example there relates to adding a fitted line - and I can't see how to relate this to my problem, which involves adding elements with "Position" and "Points" parameters.
Can anyone point me at some examples of the syntax that I might be able to adapt?
Many thanks.
New Table( "JMP Script Demo",
Add Rows( 4 ),
Compress File When Saved( 1 ),
New Script("Grid of Color-Coded Scatter Plots",
Graph Builder(
Size( 713, 469 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Grid Color( "White" ),
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables(
X( :X1 ),
X( :X2 ),
Y( :Y3A ),
Y( :Y3B, Position( 1 ) ),
Y( :Y3C, Position( 1 ) ),
Y( :Y3D, Position( 1 ) ),
Y( :Y2A ),
Y( :Y2B, Position( 2 ) ),
Y( :Y2C, Position( 2 ) ),
Y( :Y2D, Position( 2 ) )
),
Elements( Position( 1, 1 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 73 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 78 ) ) ),
Elements( Position( 2, 1 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 77 ) ) ),
Elements( Position( 2, 2 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 79 ) ) ),
SendToReport(
Dispatch( {}, "X1", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "X2", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "Y3A", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "Y2A", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
73,
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
), Legend Model(
78,
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
), Legend Model(
77,
Base( 0, 0, 0 ),
Base( 1, 0, 1 ),
Base( 2, 0, 2 ),
Base( 3, 0, 3 ),
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
), Legend Model(
79,
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
)}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Grid of Color-Coded Scatter Plots" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Y3A, Y3B, Y3C & Y3D" )} ),
Dispatch( {}, "Y 1 title", TextEditBox, {Set Text( "Y2A, Y2B, Y2C & Y2D" )} )
)
)
),
New Column( "Sample",
Character( 24 ),
"Nominal",
Set Values( {"Sample A", "Sample B", "Sample C", "Sample D"} )
),
New Column( "X1",
Numeric,
"Continuous",
Format( "Fixed Dec", 10, 2 ),
Set Values( [6.14, 5.14, 6.64, 6.72] )
),
New Column( "X2",
Numeric,
"Continuous",
Format( "Fixed Dec", 10, 2 ),
Set Values( [4.62, 4.52, 4.66, 4.84] )
),
New Column( "X3",
Numeric,
"Continuous",
Format( "Fixed Dec", 10, 2 ),
Set Values( [2.17, 2.52, 3.48, 2.25] )
),
New Column( "Y1A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [6.14, ., ., .] ) ),
New Column( "Y1B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., 5.14, ., .] ) ),
New Column( "Y1C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., 6.64, .] ) ),
New Column( "Y1D", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., 6.72] ) ),
New Column( "Y2A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [4.62, ., ., .] ) ),
New Column( "Y2B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., 4.52, ., .] ) ),
New Column( "Y2C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., 4.66, .] ) ),
New Column( "Y2D", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., 4.84] ) ),
New Column( "Y3A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2.17, ., ., .] ) ),
New Column( "Y3B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., 2.52, ., .] ) ),
New Column( "Y3C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., 3.48, .] ) ),
New Column( "Y3D", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., 2.25] ) ),
Set Row States( [8, 8, 8, 8] ),
Set Label Columns( :Sample )
)