/*
After save dt into Journal, the cell color from data data table was changed into the font color in the journal
*/
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Color by Column( :age);
Wait( 0 );
dt << Color Rows by Row State;
dt<<SAVE></SAVE>
您拥有哪个版本的 JMP?您使用的是这个脚本还是修改后的脚本? 如有修改,请附上。
表消息dt << 按行状态对行着色()似乎是一个“视图”声明。 表视图已更改,但保存表并打开它或记录日志不会保留彩色单元格。记录该表将在日志中创建一个报告,其中表字体颜色与行状态颜色匹配。
然而, col << 颜色单元格( clr, rows)是一个列消息。 该消息存储在表列的属性中。 此外,在记录日志时,细胞颜色也会保持不变。
下面显示了脚本和结果。 请注意,另一种方法(可能更直接)是获取每个组(年龄)的唯一键,获取每个年龄的行,然后选择一种颜色并将其应用到每列的这些行。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Color by Column( :age );
Wait( 0 );
//This next command does not save the cell colors.
//dt << Color Rows by Row State;
dt << Clear column selection();
dt << clear select;
//get the unique colors
nr = N Row( dt );
//make a list the size of the table to get the row colors and locate rows of a given color
_clr = As List( J( nr, 1, 0 ) );
For( i = 1, i <= N Row( dt ), i++,
_clr[i] = Color To RGB( Color Of( Row State( i ) ) )
);
//creates a list of unique colors
clr_keys = Associative Array( _clr ) << get keys;
//for each color (j), locate which rows are assigned that color using Loc( _clr, ...)
For( j = 1, j <= N Items( clr_keys ), j++,
idx = Loc( _clr, clr_keys[j] );
//Color the cells in rows idx and each coloumn
For( i = 1, i <= N Col( dt ), i++,
Column( dt, i ) << color cells( RGB Color( clr_keys[j] ), idx )
);
);
//now journal the table
dt << journal;
