【问题标题】:Manipulate Custom Tabular representation in Mathematica在 Mathematica 中操作自定义表格表示
【发布时间】:2011-06-13 16:56:51
【问题描述】:

考虑以下数据示例:

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。 最终我也会操纵他提供的选项,现在)

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, Length@data[[1]] - 1, 1]]
PopupMenu[Dynamic[range2], Range[2, Length@data[[1]], 1]]
PopupMenu[Dynamic[linesNumber], Range[2, Length@data[[All, 1]] - 1, 1]]
Dynamic[DataSampleX[data, linesNumber, range1, range2, LightBlue, 
LightGray, LightYellow]]

如何使用 setter 更新颜色值?

是否可以在 Manipulate 窗口中实际使用它?

欢迎任何其他使这种高效看起来不错的建议。

-编辑:感谢下面的 Belisarius 解决方案,我现在能做什么:

【问题讨论】:

    标签: dynamic wolfram-mathematica tabular


    【解决方案1】:

    尝试类似:

    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[{
        Control@{{range1,      1, s@"Range1"}, Range[1, Length@data[[1]] - 1],  ct}, 
        Control@{{range2,      2, s@"Range2"}, Range[2, Length@data[[1]] - 1],  ct}, 
        Control@{{linesNumber, 2, s@"Lines"},  Range[2,Length@data[[All, 1]]-1],ct}}],
       Spacer[20],
       Column[{
         Control@{{color1, colsel[[1, 1]], s@"Color 1"}, colsel, ct}, 
         Control@{{color2, colsel[[2, 1]], s@"Color 2"}, colsel, ct}, 
         Control@{{color3, colsel[[3, 1]], s@"Color 3"}, colsel, ct}}]
     }]]
    

    【讨论】:

    • @500 你不喜欢 Mma 的那些小技巧,比如在你应该放一些文字的地方显示一个彩色磁盘吗?
    • @Belisarius,你将如何防止控制中的 range1 > range2 ?
    • @500 尝试在 range1 限制规范中使用 Range[1,range2]
    • @Belisarius,鉴于您解决和扩展我的问题的速度和优雅程度,我有一个梦想:所有列标题都可以成为您单击以将其添加到显示的设置器按钮。与其设置范围,不如单击他希望显示的列的所有名称。这是可行的吗?我会发布一个新问题!
    • @500 这些是“索引”颜色图。 ColorData[1], ... ColorData[62] ...无需使用“名称”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-13
    • 1970-01-01
    • 2012-04-26
    • 1970-01-01
    • 2014-12-17
    • 1970-01-01
    相关资源
    最近更新 更多