Hi,
I am trying to write a general purpose graph builder function to deal with different graph conditions (with or without overlay, with or without wrap, etc.), The following script works for my three cases, but the smoother (not sure if it is the linear or curve fit) is on for the first and second graphs, and not the third.
I don't think I am doing anything to turn on the smoother(s) in my script. My question is how do I turn off the smoother(s) via scripting?
Thanks,
Bill
Clear Globals();
Names Default To Here( 1 );
//Open the file
myFile = Pick File( "Choose File" );
dtIn = Open( myFile );
//Extract Serial number
for(i=1, i<=nrow(dtIn), i++,
dtIn:SERIAL_NUMBER[i] = regex(dtIn:SERIAL_NUMBER[i], "\w{8}");
);
dtIn:PE_COUNTS_DIE_LOGICAL_DIE_INDEX << set modeling type("Nominal");
DoGraph = function({dt, xCol, yCols, wrapCol, overlayCol},
{default local},
current data table(dt);
myExpr = expr(Graph Builder(
Size( 528, 490 ),
Show Control Panel( 0 ),
)
);
varExpr = expr(Variables());
elementExpr = expr(Elements());
pointsExpr = expr(Points( X ));
xExpr = expr(X(as column(expr(xCol))));
insert into(varExpr, name expr(xExpr), 1);
if( is string(yCols),
yExpr = expr(Y(:expr(yCols)));
insert into(varExpr, name expr(yExpr), 2);
nextIndex = 3;
,
is list(yCols),
nYCols = n items(yCols);
for(i=1, i<=nYCols, i++,
yStr = yCols[i];
yExpr = expr(Y(as column(expr(yStr)), Position( 1 )));
yExpr1 = eval expr(yExpr);
insert into(varExpr, name expr(yExpr1), i+1);
yPointExpr = expr(Y(expr(i)));
yPointExpr1 = eval expr(yPointExpr);
insert into(pointsExpr, name expr(yPointExpr1), i+1);
);
insert into(elementExpr, name expr(pointsExpr));
nextIndex = nYCols + 2;
,
Throw("Y must be string or list of strings");
);
if(length(wrapCol),
wrapExpr = expr(Wrap(:expr(wrapCol)));
insert into(varExpr, name expr(wrapExpr), nextIndex);
nextIndex++;
);
if(length(overlayCol),
overlayExpr = expr(Overlay(:expr(overlayCol)));
insert into(varExpr, name expr(overlayExpr), nextIndex);
nextIndex++;
);
insert into(myExpr, name expr(varExpr), 3);
insert into(myExpr, name expr(elementExpr), 4);
myExpr1 = expr(eval expr(myExpr));
eval(myExpr1);
);
xCol = "DRIVE_LEVEL_DATA_PE_AVE_DL_AVE";
yCol = "DIE_AGE_DIE_AGE";
hpList = {
"DRIVE_VITALS_AGE_SBS_THAT_PERFORMED_AGE_MEASUREMENT",
"DRIVE_VITALS_AGE_SBS_THAT_WENT_INTO_THE_HOLDING_PEN",
"DRIVE_VITALS_AGE_OCCURANCES_OF_SBS_SKIPPED_THE_HOLDING_PEN_BECAUSE_IT_WAS_FULL",
"DRIVE_VITALS_AGE_SBS_THAT_ABORTED_AGE_MEASUREMENT"
};
DoGraph(dtIn, xCol, "DIE_AGE_DIE_AGE", "SERIAL_NUMBER", "PE_COUNTS_DIE_LOGICAL_DIE_INDEX");
DoGraph(dtIn, xCol, "DRIVE_LEVEL_DATA_DIE_AGE_DL_AVE", "SERIAL_NUMBER", "");
DoGraph(dtIn, xCol, hpList, "SERIAL_NUMBER", "");You could manipulate the Graph Builder preferences so the smoother never appears in the first place. Or you could do this kind of thing:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 5 ) ), Smoother( X, Y, Legend( 6 ) ) )
);
Wait(2);
gbb = Report( gb )[Graph Builder Box( 1 )];
Print(gbb << Get Elements( 1, 1 ));
gbb << removeElement(1, 1, 2);
Print(gbb << Get Elements( 1, 1 ));Hi Ian,
Thank you for your response. Ideally I would like to prevent the smoother from being on in the first place. I tried figuring out how to manipulate graph builder preferences, but the only related scriting index item I found was "Ignore Platform Preferences( 1 )", and this did not seem to have any impact. One thing that concerns me is that the default behavior varies between my three cases.
Any suggestions on what scripting synatax can access graph builder preferences?
Thanks,
Bill
I found the magic bullet after a little digging:
set platform preferences(graph builder(Continuous Smoother( 0 )));
Thanks for pointing me in the right direction Ian.