/*
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;
