cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
lwx228
Level VIII

How to use JSL to color local cells by value?

For example, in the "weight" column of "Big class.jMP ", take the data in rows 1-10 and make the gradient color by data height, as in the Image.So can start and stop any color  want.

 

2020-07-05_21-55.png

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: How to use JSL to color local cells by value?

colors.PNG

Here is a script that will color the column weight's first 10 rows in the data table.

names default to here(1);
dt=Open("$SAMPLE_DATA/big class.jmp");

// Set the gradient list of colors
colorList = {-2768895, -5530606, -6582759, -8094941, -9147350, -10462158, -11514567, -12237762,
-13344414, -14575206};

// Color first 10 rows

// find the range
weightMin= col min(if(Row()<=10,:weight,.));
weightMax= col max(if(Row()<=10,:weight,.));
weightInc= (weightMax-weightmin)/10;

// Loop across and set the colors
For(i=1,i<=10,i++,
	Bin=floor((:weight[i]-weightMin)/weightInc)+1;
	if(Bin>10,Bin=10);
	:weight << color cells( colorList[bin],i)
);

To understand all of the concepts behind the colors in JMP, you need to read the documentation in the Scripting Guide on Specifying Colors

Jim

View solution in original post

pmroz
Super User

Re: How to use JSL to color local cells by value?

What OS and JMP version(s) are you using?  I'm using JMP 14 on Windows 10, 64-bit.

Try these steps:

  • Open Big Class
  • Right click on height > Column Properties > Color Gradient

Big Class Gradient3.png

  • Check "Color Cell by Value", then OK

Big Class Gradient4.png

  • You should end up with this:

Big Class Gradient5.png

If this still doesn't work you'll need to contact the JMP helpdesk.

View solution in original post

26 REPLIES 26
lwx228
Level VIII

Re: How to use JSL to color local cells by value?

"Color scales" were not found on the script index.

 

  • Thanks!

txnelson
Super User

Re: How to use JSL to color local cells by value?

colors.PNG

Here is a script that will color the column weight's first 10 rows in the data table.

names default to here(1);
dt=Open("$SAMPLE_DATA/big class.jmp");

// Set the gradient list of colors
colorList = {-2768895, -5530606, -6582759, -8094941, -9147350, -10462158, -11514567, -12237762,
-13344414, -14575206};

// Color first 10 rows

// find the range
weightMin= col min(if(Row()<=10,:weight,.));
weightMax= col max(if(Row()<=10,:weight,.));
weightInc= (weightMax-weightmin)/10;

// Loop across and set the colors
For(i=1,i<=10,i++,
	Bin=floor((:weight[i]-weightMin)/weightInc)+1;
	if(Bin>10,Bin=10);
	:weight << color cells( colorList[bin],i)
);

To understand all of the concepts behind the colors in JMP, you need to read the documentation in the Scripting Guide on Specifying Colors

Jim
lwx228
Level VIII

Re: How to use JSL to color local cells by value?

Thank Jim!

 

I searched the index and saw only this.
Where I can see a more complete color code?

2020-07-06_15-28.png

txnelson
Super User

Re: How to use JSL to color local cells by value?

Look in the Scripting Guide.......not just the Scripting Index
Jim
pmroz
Super User

Re: How to use JSL to color local cells by value?

You can also try color gradient.

dt = open("$sample_data\Big Class.jmp");

bmin = col min(dt:height);
bmax = col max(dt:height);
bavg = col mean(dt:height);

dt:height << set property("Color Gradient", {"Light Spectral", Range( {bmin, bmax, bavg} )});
dt:height << Color Cell by Value(1);

This will color the entire column.  You can use color cells for rows 11 to the end to remove the color.

lwx228
Level VIII

Re: How to use JSL to color local cells by value?

Thank pmroz!


Is your code complete?I didn't see any results when I ran it, and I didn't know how to perfect the code.Thanks for your help!
pmroz
Super User

Re: How to use JSL to color local cells by value?

You should see this:

Big Class Gradient.png

pmroz
Super User

Re: How to use JSL to color local cells by value?

Here's how to only show the color gradient for rows 1-10.  Note that the min, max and mean are calculated on the entire column.  You can adjust that.

dt = open("$sample_data\Big Class.jmp");

bmin = col min(dt:height);
bmax = col max(dt:height);
bavg = col mean(dt:height);

dt:height << set property("Color Gradient", {"Light Spectral", Range( {bmin, bmax, bavg} )});
dt:height << Color Cell by Value(1);

reset_rows = 11::40;
dt:height << color cells ("White", reset_rows);

Big Class Gradient2.png

lwx228
Level VIII

Re: How to use JSL to color local cells by value?

Thank pmroz!

 

Strange, I still don't see 1-10 lines of color here.Lines 11 to 40 are white.

 

2020-07-08_06-46.png