Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- How to use JSL to color local cells by value?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 5, 2020 7:05 AM
(884 views)

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.

2 ACCEPTED SOLUTIONS

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

- Check "Color Cell by Value", then OK

- You should end up with this:

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

26 REPLIES 26

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

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

Thanks!

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Look in the Scripting Guide.......not just the Scripting Index

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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!

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!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

You should see this:

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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);
```

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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