cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
itzikd
Level II

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

Grouptest1test2test311
BL11111
BL222265
BL233611
POR22222
Value111134
POR57222
Value175173
Value222222
Value081116

 

if i do it by hand its like this:

 

itzikd_0-1621320193160.png

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

itzikd_1-1621320329850.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: JSL creating a spine line for changing group each time

Hi,

 

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;

View solution in original post

2 REPLIES 2

Re: JSL creating a spine line for changing group each time

Hi,

 

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;
itzikd
Level II

Re: JSL creating a spine line for changing group each time

thanks 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] ))
	);