For the latest version of JMP Help, visit JMP.com/help.

Scripting Guide > Data Tables > Rows > Color Cells
Publication date: 09/28/2021

Color Cells

You can color individual cells in the data grid. For example, this line uses the row state color to color the cells:

dt << Color Rows by Row State;

You can also specify a color theme for either categorical or continuous columns:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
:height << Set Property(
	"Color Gradient",
	{"White to Blue", Range( 40, 80 )}
);
:height << Color Cell By Value( 1 ); // turn on the cell coloring
 
:age << Set Property(
	"Value Colors", // assign the value colors
	{12 = Red, 13 = Yellow, 14 = Green, 15 = Blue, 16 = Magenta, 17 =
	Gray}
);
 
:age << Color Cell By Value( 0 ); // turn off the cell coloring
 

You can also color specific cells. The following example sets rows 1, 5, 8 of the “name” column to red:

:name << Color Cells( red, {1, 5, 8} );

To remove the color from specific cells, set the color to black. The following example removes the color for row 1 of the “name” column.

:name << Color Cells( black, {1} );

You can color cells based on specific values. The following example colors the cells in the height column. All cells containing a value greater than 60 are blue. All cells containing a value equal to or less than 60 are purple.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
For( i = 1, i <= N Row( dt ), i++,
	If( Column( dt, "height" )[i] > 60,
		Column( dt, "height" ) << Color Cells( 5, {i} ),
		Column( dt, "height" ) << Color Cells( 8, {i} )
	)
);

Note: The first argument for Color Cells represents the color value. The second argument contains the row numbers.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).