I am trying to recreate the script below using a loop (this script works, but I would like it to run as a loop so that it treats each data set the same way):
bivariate(
Y( :name( "1st Thickness PST" ) ),
X( :site ),
By( :Lot ),
Fit Where( :Slot_id == 1, Fit Each Value( {Line Color( {213, 72, 87} )} ) ),
Fit Where( :Slot_id == 2, Fit Each Value( {Line Color( {57, 177, 67} )} ) ),
Fit Where( :Slot_id == 3, Fit Each Value( {Line Color( {64, 111, 223} )} ) ),
Fit Where( :Slot_id == 4, Fit Each Value( {Line Color( {207, 121, 38} )} ) ),
Fit Where( :Slot_id == 5, Fit Each Value( {Line Color( {33, 189, 145} )} ) ),
Fit Where( :Slot_id == 6, Fit Each Value( {Line Color( {161, 44, 220} )} ) ),
Fit Where( :Slot_id == 7, Fit Each Value( {Line Color( {200, 193, 39} )} ) ),
Fit Where( :Slot_id == 8, Fit Each Value( {Line Color( {31, 182, 182} )} ) ),
Fit Where( :Slot_id == 9, Fit Each Value( {Line Color( {201, 37, 205} )} ) ),
Fit Where( :Slot_id == 10, Fit Each Value( {Line Color( {145, 183, 32} )} ) ),
Fit Where( :Slot_id == 11, Fit Each Value( {Line Color( {35, 157, 195} )} ) ),
Fit Where( :Slot_id == 12, Fit Each Value( {Line Color( {210, 38, 158} )} ) ),
Fit Where( :Slot_id == 13, Fit Each Value( {Line Color( {141, 165, 48} )} ) ),
Fit Where( :Slot_id == 14, Fit Each Value( {Line Color( {106, 191, 140} )} ) ),
Fit Where( :Slot_id == 15, Fit Each Value( {Line Color( {23, 67, 132} )} ) ),
Fit Where( :Slot_id == 16, Fit Each Value( {Line Color( {144, 81, 160} )} ) ),
Fit Where( :Slot_id == 17, Fit Each Value( {Line Color( {220, 133, 105} )} ) ),
Fit Where( :Slot_id == 18, Fit Each Value( {Line Color( {97, 136, 48} )} ) ),
Fit Where( :Slot_id == 19, Fit Each Value( {Line Color( {41, 228, 161} )} ) ),
Fit Where( :Slot_id == 20, Fit Each Value( {Line Color( {155, 162, 199} )} ) ),
Fit Where( :Slot_id == 21, Fit Each Value( {Line Color( {109, 28, 105} )} ) ),
Fit Where( :Slot_id == 22, Fit Each Value( {Line Color( {160, 109, 62} )} ) ),
Fit Where( :Slot_id == 23, Fit Each Value( {Line Color( {127, 228, 79} )} ) ),
Fit Where( :Slot_id == 24, Fit Each Value( {Line Color( {53, 113, 105} )} ) ),
Fit Where( :Slot_id == 25, Fit Each Value( {Line Color( {55, 42, 208} )} ) ),
SendToReport(
Dispatch( {}, "1", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "2", ScaleBox, {Minor Ticks( 1 ), Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 655, 344 ), Marker Size( 3 )} )
)
);
This generates the data that I need but I don't understand why the script below does not. It will generate a plot but without "fit each value" lines and color assignments for each slot_id in the loop
R = [213, 57, 64, 207, 33, 161, 200, 31, 201, 145, 35, 210, 141, 106, 23, 144, 220, 97, 41, 155, 109, 160, 127, 53, 55];
G = [72, 177, 111, 121, 189, 44, 193, 182, 37, 183, 157, 38, 165, 191, 67, 81, 133, 136, 228, 162, 28, 109, 228, 113, 42];
B = [87, 67, 223, 38, 145, 220, 39, 182, 205, 32, 195, 158, 48, 140, 132, 160, 105, 48, 161, 199, 105, 62, 79, 105, 208];
SlotNums = Associative Array( :slot_id );
UniqueSlots = slotnums << get keys;
For( i = 1, i <= N Items( uniqueslots ), i++,
If( i == 1,
lines = Eval(
"Fitwhere(:Slot_id == " || Char( uniqueslots[i] ) || ", " || "Fit Each Value( {Line Color( {" || Char( R[i] ) || ", " || Char( G[i] ) ||
", " || Char( B[i] ) || "} )} )),"
)
);
If( i < N Items( uniqueslots ),
Lines = Char( lines ) || Eval(
"Fitwhere(:Slot_id == " || Char( uniqueslots[i] ) || ", " || "Fit Each Value( {Line Color( {" || Char( R[i] ) || ", " || Char( G[i] ) ||
", " || Char( B[i] ) || "} )} )),"
)
);
If( i == N Items( uniqueslots ),
Lines = Char( lines ) || Eval(
"Fitwhere(:Slot_id == " || Char( uniqueslots[i] ) || ", " || "Fit Each Value( {Line Color( {" || Char( R[i] ) || ", " || Char( G[i] ) ||
", " || Char( B[i] ) || "} )} ))"
)
);
);
bivariate(
Y( :name( "1st Thickness PST" ) ),
X( :site ),
By( :Lot ),
Parse( lines ),
SendToReport(
Dispatch( {}, "1", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "2", ScaleBox, {Minor Ticks( 1 ), Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 655, 344 ), Marker Size( 3 )} )
)
);
Can anyone suggest a method for getting this to work?