JSL creating a spine line for changing group each time
Hello,
I have this script:
dt = Current Data Table();
listX = {"1","2"};
listY = {"test1", "test2", "test3"};
fybx = dt << FitYByX(
Y( Eval( listY ) ),
X( Eval( listX ) ),
Fit Where( :Group == "BL", Fit Spline( 0.1, Standardized, {Line Color( {213, 72, 87} )} ) ),
try(Fit Where( :Group == "Value0", Fit Spline( 0.1, Standardized, {Line Color( {57, 177, 67} )} ) )),
try(Fit Where( :Group == "Value1", Fit Spline( 0.1, Standardized, {Line Color( {64, 111, 223} )} ) )),
try(Fit Where( :Group == "Value2", Fit Spline( 0.1, Standardized, {Line Color( {207, 121, 38} )} ) )),);it creates x by y graphs based on a list, I am now trying to add a spine line but I have 2 problems:
1. the spine line should be created based on "Group" column and it might have different values (like "Value1" might be "Value4" or "Value0" can be "Value34" sometimes) so I need to find a way to create this with a list if possible
2. it creates 1 spine line and not 4 like I want
my table
| Group | test1 | test2 | test3 | 1 | 1 |
| BL | 1 | 1 | 1 | 1 | 1 |
| BL | 2 | 2 | 2 | 2 | 65 |
| BL | 23 | 3 | 6 | 1 | 1 |
| POR | 2 | 2 | 2 | 2 | 2 |
| Value1 | 1 | 1 | 1 | 3 | 4 |
| POR | 5 | 7 | 2 | 2 | 2 |
| Value1 | 7 | 5 | 1 | 7 | 3 |
| Value2 | 2 | 2 | 2 | 2 | 2 |
| Value0 | 8 | 1 | 1 | 1 | 6 |
if i do it by hand its like this:

and then I pick by "Group" (I believe I need to add this to the script somehow)
then I click "flexible" --> "fit spline" --> mark the "standardize x" and click "ok"
and last thing I add is row legend

Advanced Statistical ModelingData Blending and CleanupMass CustomizationRe: JSL creating a spine line for changing group each timethanks so much! this works!
in case anyone wants different colors in spine line
ColorList = {};
AList = {207, 121, 38};
BList = {64, 111, 223};
CList = {57, 177, 67};
DList = {213, 72, 87};
InsertInto(ColorList, EvalList(List(AList)));
InsertInto(ColorList, EvalList(List(BList)));
InsertInto(ColorList, EvalList(List(CList)));
InsertInto(ColorList, EvalList(List(DList)));
for (i = 1, i<=nitems(groupList), i++,
insertinto(bivExpr, substitute(expr(Fit Where( :Group == _XX_, Fit Spline( 0.1, {Line Color( _YY_ )} ))), expr(_XX_), groupList[i],expr(_YY_), ColorList[i] ))
);Re: JSL creating a spine line for changing group each timeHi,
I think you're going to need to look at expression handling for this. You will start with an expression, and insert things into it... specifically you'll be adding the fit spline details into the fit y by x expression.
Expression handling has a steep learning curve, but is very powerful.
See if this gets you on the path you want. Notice the combination of Insert Into() along with a Substitute(), which substitutes the various group levels in for _XX_ in the original expression.
Cheers,
Brady
names default to here(1);
dt = current data table();
listX = {"1","2"};
listY = {"test1", "test2", "test3"};
bivExpr = expr(
Bivariate(
Y( evallist(listY) ),
X( evallist(listx) ),
)
);
groupList = (associative array(dt:group << get values)) << get keys;
for (i = 1, i<=nitems(groupList), i++,
insertinto(bivExpr, substitute(expr(Fit Where( :Group == _XX_, Fit Spline( 0.1, {Line Color( {212, 73, 88} )} ))), expr(_XX_), groupList[i] ))
);
show(nameexpr(bivExpr));
bivExpr;