MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Freeze Panes in Grid Expression (addendum)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105139] Re: [mg105060] Freeze Panes in Grid Expression (addendum)
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 22 Nov 2009 06:09:15 -0500 (EST)
  • Reply-to: hanlonr at cox.net

This is a minor modification. In the first case (both scrolls) for scrollMatrix I had forgotten to simplify it using the conditions.

scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] :=
 Module[{maxR},
   maxR = Length[m] - rows + 2;
   Manipulate[
    Grid[
     Drop[m[[1 ;; maxR + rows - r]], 2 ;; maxR - r + 1]
      [[All, {1, Sequence @@ Range[c, c + columns - 2]}]],
     Dividers -> {{False, True}, {False, True}}],
    {{r, maxR}, 2, maxR, 1,
     ControlType -> VerticalSlider},
    {c, 2, Length[m[[1]]] - columns + 2, 1},
    ControlPlacement -> {Left, Top}]] /; 
  rows < Length[m] &&
   columns < Length[m[[1]]]

scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] :=
 Module[{maxR = Length[m] - rows + 2},
   Manipulate[
    Grid[
     Drop[m[[1 ;; maxR + rows - r]], 2 ;; maxR - r + 1],
     Dividers -> {None, {False, True}}],
    {{r, maxR}, 2, maxR, 1,
     ControlType -> VerticalSlider},
    ControlPlacement -> Left]] /; rows < Length[m]

scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] :=
 Manipulate[
   Grid[
    m[[All, {1, Sequence @@ Range[c, c + columns - 2]}]],
    Dividers -> {{False, True}, None}],
   {c, 2, Length[m[[1]]] - columns + 2, 1}] /; columns < Length[m[[1]]]

scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] :=
 Grid[m]

m = Array[a, {3, 3}];

scrollMatrix[m, 6, 5]

m = Array[a, {15, 3}];

scrollMatrix[m, 6, 5]

m = Array[a, {3, 15}];

scrollMatrix[m, 6, 6]

m = Array[a, {15, 15}];

scrollMatrix[m, 6, 6]


Bob Hanlon

---- Thomas Melehan <tpmelehan at me.com> wrote: 

=============
Thanks, thats really helpful..
I owe you a beer.

On Nov 21, 2009, at 2:53 PM, Bob Hanlon wrote:

> The following suppresses scroll bars that are not needed and uses VerticalSlider for scrolling rows (with direction reversed).
> 
> 
> scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] := 
> Module[{maxR,
>    nC = Min[columns, Length[m[[1]]]],
>    nR = Min[rows, Length[m]]},
>   maxR = Length[m] - nR + 2;
>   Manipulate[
>    Grid[
>     Drop[m[[1 ;; maxR + nR - r]], 2 ;; maxR - r + 1]
>      [[All, {1, Sequence @@ Range[c, c + nC - 2]}]],
>     Dividers -> {{False, True}, {False, True}}],
>    {{r, maxR}, 2, maxR, 1,
>     ControlType -> VerticalSlider},
>    {c, 2, Length[m[[1]]] - nC + 2, 1},
>    ControlPlacement -> {Left, Top}]] /; 
>  rows < Length[m] &&
>   columns < Length[m[[1]]]
> 
> scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] := 
> Module[{maxR = Length[m] - rows + 2},
>   Manipulate[
>    Grid[
>     Drop[m[[1 ;; maxR + rows - r]], 2 ;; maxR - r + 1],
>     Dividers -> {None, {False, True}}],
>    {{r, maxR}, 2, maxR, 1,
>     ControlType -> VerticalSlider},
>    ControlPlacement -> Left]] /; rows < Length[m]
> 
> scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] :=
> Manipulate[
>   Grid[
>    m[[All, {1, Sequence @@ Range[c, c + columns - 2]}]],
>    Dividers -> {{False, True}, None}],
>   {c, 2, Length[m[[1]]] - columns + 2, 1}] /; columns < Length[m[[1]]]
> 
> scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] :=
> Grid[m]
> 
> m = Array[a, {3, 3}];
> 
> scrollMatrix[m, 6, 5]
> 
> m = Array[a, {15, 3}];
> 
> scrollMatrix[m, 6, 5]
> 
> m = Array[a, {3, 15}];
> 
> scrollMatrix[m, 6, 6]
> 
> m = Array[a, {15, 15}];
> 
> scrollMatrix[m, 6, 6]
> 
> 
> Bob Hanlon
> 
> ---- Bob Hanlon <hanlonr at cox.net> wrote: 
> 
> =============
> 
> scrollMatrix[m_?MatrixQ, rows_Integer, columns_Integer] :=
> Module[{
>   nC = Min[columns, Length[m[[1]]]],
>   nR = Min[rows, Length[m]]},
>  Manipulate[
>   Grid[
>    Drop[m[[1 ;; r + nR - 2]], 2 ;; r - 1]
>     [[All, {1, Sequence @@ Range[c, c + nC - 2]}]],
>    Dividers -> {{False, True}, {False, True}}],
>   {r, 2, Length[m] - nR + 2, 1},
>   {c, 2, Length[m[[1]]] - nC + 2, 1}]]
> 
> m = Array[a, {15, 10}];
> 
> scrollMatrix[m, 10, 5]
> 
> 
> Bob Hanlon
> 
> ---- Thomas Melehan <tpmelehan at me.com> wrote: 
> 
> =============
> Folks: I often generate a 2D matrix that I would love to be able to view in Mathematica as one does in say Excel, by freezing the window at a certain column and scrolling thru the rest of the columns to the right of the frozen column.  I can take the expression and dump it into Excel but it is somewhat time consuming.  Does anyone know how to directly achieve this in Mathematica, by say using two panels?
> 
> 




  • Prev by Date: Re: Beta Cube - Wolfram Demonstrations Project
  • Next by Date: Re: Re: Mathematica scoping / contexts / variable localization
  • Previous by thread: Re: Freeze Panes in Grid Expression (addendum)
  • Next by thread: "If" syntax question