cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Thierry_S
Super User

Windows 11 > JMP 19 > Script to Assign Continuous Gradient > Issue with Passing the Gradient Range to the Column Property

Hi JMP Community,

I wrote a simple script to assign a color gradient to continuous-value columns based on the 0.05 quantile of columns values.

Names Default To Here(1);

dt = current data table ();

scol = dt << Get Selected Columns ();

For (i = 1, i <= N items (scol), i++,
	column (dt, scol[i]) << Format("Fixed Dec", 12, 3);
	low_mark = Col Quantile(column (dt, scol[i]), 0.05);
	high_mark = Col Quantile(column (dt, scol[i]), 0.95);
	
	if(abs(low_mark) > high_mark, bound = -low_mark, bound = high_mark);
	
	range_list = {-bound, bound, 0};
	
	column (dt, scol[i]) << Set Property ("Color Gradient", 
										{"Blue White Red", Range (Eval list (range_list)),
										Color cell by value (1)})
	
	
);

While it works in assigning the  correct colors, JMP returns an error when I subsequently edit the gradient manually (see below):

JMP ERROR.png

 

 

 

 

Hence, I need a method to pass the gradient range values without triggering an error upon subsequent manual edits.

Thank you.

Best,

TS

 

 

Thierry R. Sornasse
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Windows 11 > JMP 19 > Script to Assign Continuous Gradient > Issue with Passing the Gradient Range to the Column Property

You are missing expression evaluation

Names Default To Here(1);

dt = Current Data Table();

scol = dt << Get Selected Columns("String");

For Each({colname}, scol,
	Column(dt, colname) << Format("Fixed Dec", 12, 3);
	low_mark = Col Quantile(Column(dt, colname), 0.05);
	high_mark = Col Quantile(Column(dt, colname), 0.95);
	
	If(Abs(low_mark) > high_mark,
		bound = -low_mark,
		bound = high_mark
	);
	
	range_list = Eval List({-bound, bound, 0});

	Eval(EvalExpr(
		Column(dt, colname) << Set Property(
			"Color Gradient",
			{"Blue White Red", Range(Expr(range_list)), Color cell by value(1)}
		)		
	));
);
-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Windows 11 > JMP 19 > Script to Assign Continuous Gradient > Issue with Passing the Gradient Range to the Column Property

You are missing expression evaluation

Names Default To Here(1);

dt = Current Data Table();

scol = dt << Get Selected Columns("String");

For Each({colname}, scol,
	Column(dt, colname) << Format("Fixed Dec", 12, 3);
	low_mark = Col Quantile(Column(dt, colname), 0.05);
	high_mark = Col Quantile(Column(dt, colname), 0.95);
	
	If(Abs(low_mark) > high_mark,
		bound = -low_mark,
		bound = high_mark
	);
	
	range_list = Eval List({-bound, bound, 0});

	Eval(EvalExpr(
		Column(dt, colname) << Set Property(
			"Color Gradient",
			{"Blue White Red", Range(Expr(range_list)), Color cell by value(1)}
		)		
	));
);
-Jarmo

Recommended Articles