2011-06-13 66 views
2

考慮以下數據例如:操縱數學定製表格表示

data ={ 
     {"a", "b", "c", "d", "e"}, 
     {1, 2, 3, 4, 5}, 
     {11, 12, 13, 14, 15}, 
     {21, 22, 23, 24, 25} 
     }; 

而下面的函數來生成定製的表格表示:

(你可以參考Mr.Wizard extensive solution for customizable tabular representations Ultimatly我也會操縱他提供的選項,現在)

DataSampleX[data_, linesNumber_, range1_, range2_, color1_, color2_, color3_] := 

Grid[ 
Join[ 
     {Range[range1, range2]}, {Map[Rotate[Text[#], 90 Degree] &, 
     data[[1, range1 ;; range2]]]}, 
     data[[2 ;; linesNumber, range1 ;; range2]] 
    ], 
     Background -> {{{{color1, color2}}, {1 -> color3}}}, 
     Dividers  -> {All, {1 -> True, 2 -> True, 3 -> True,0 -> True}}, 
     ItemSize  -> {1 -> Automatic, Automatic}, 
     Alignment  -> Top, 
     Frame   -> True, 
     FrameStyle -> Thickness[2], 
     ItemStyle  -> {Automatic, Automatic, 
         {{1, 1}, {1, Length[data]}} ->Directive[FontSize -> 
         15, Black, Bold]} 
    ]; 

我想使用Manipulate或Dynamic來顯示我的數據部分使用上述。 這選擇我想要顯示的列的範圍,要顯示的行數以及顏色。

以下是我未完成的嘗試。

PopupMenu[Dynamic[range1], Range[1, [email protected][[1]] - 1, 1]] 
PopupMenu[Dynamic[range2], Range[2, [email protected][[1]], 1]] 
PopupMenu[Dynamic[linesNumber], Range[2, [email protected][[All, 1]] - 1, 1]] 
Dynamic[DataSampleX[data, linesNumber, range1, range2, LightBlue, 
LightGray, LightYellow]] 

enter image description here

enter image description here

我怎麼能使用setter方法來更新顏色值?

是否有可能在Manipulate窗口中實際使用此功能?

任何其他建議,使這種效率看起來不錯,是值得歡迎的。

- 編輯:我怎麼能現在要做得益於以下貝利薩留的解決方案:

enter image description here

回答

2

試着這麼做:

colsel = (#->Graphics[{#, Disk[]},ImageSize -> 15])& /@ColorData[1, "ColorList"]; 
s[x_] := Style[x, Black, Bold, 12]; 
ct = ControlType -> PopupMenu; 

Manipulate[ 
DataSampleX[data, linesNumber, range1, range2, color1, color2, color3], 
Row[{ 
    Column[{ 
    [email protected]{{range1,  1, [email protected]"Range1"}, Range[1, [email protected][[1]] - 1], ct}, 
    [email protected]{{range2,  2, [email protected]"Range2"}, Range[2, [email protected][[1]] - 1], ct}, 
    [email protected]{{linesNumber, 2, [email protected]"Lines"}, Range[2,[email protected][[All, 1]]-1],ct}}], 
    Spacer[20], 
    Column[{ 
    [email protected]{{color1, colsel[[1, 1]], [email protected]"Color 1"}, colsel, ct}, 
    [email protected]{{color2, colsel[[2, 1]], [email protected]"Color 2"}, colsel, ct}, 
    [email protected]{{color3, colsel[[3, 1]], [email protected]"Color 3"}, colsel, ct}}] 
}]] 

enter image description here

+0

@Belisarius,謝謝你! – 500 2011-06-13 18:24:56

+0

@ 500你不喜歡Mma的那些小技巧,比如在你應該放置一些文本的地方顯示一個彩色的磁盤? – 2011-06-13 18:31:58

+0

@Belisarius,你會如何防止控制範圍range1> range2? – 500 2011-06-13 18:33:08