Re: Creating a Grid with square cells
- To: mathgroup at smc.vnet.net
- Subject: [mg112780] Re: Creating a Grid with square cells
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Thu, 30 Sep 2010 04:51:42 -0400 (EDT)
- References: <205496.78272.qm@web52602.mail.re2.yahoo.com>
Hi Anthony, The last column is rectangular in order to accommodate the number 10, which is larger than all other numbers in the grid. About the changing line widths: could you provide an example of this? Cheers -- Sjoerd -----Original Message----- From: Anthony Hodsdon [mailto:ajhodsd at yahoo.com] Sent: Tuesday 28 September 2010 05:40 To: sjoerd.c.devries at gmail.com Subject: [mg112780] Re: Creating a Grid with square cells Weird. It looks like this mail never made it to the forums. --Anthony ----- Original Message ---- From: Anthony Hodsdon <ajhodsd at yahoo.com> To: mathgroup at smc.vnet.net Sent: Sat, September 25, 2010 11:52:13 AM Subject: [mg112780] Re: Creating a Grid with square cells Hi, Sjoerd. Thanks for the suggestion! I wasn't aware of the ImageSizeAction. Unfortunately, that doesn't quite seem to work. Here's another example that illustrates the problem better: Pane[Grid[Table[i + j, {i, 0, 5}, {j, 0, 5}], Frame -> All, Background -> {3 -> LightBlue}, ItemStyle -> 10, Alignment -> {Center, Center}], ImageSize -> 300, ImageSizeAction -> "ResizeToFit"] Note that the right-most column is distinctly rectangular. When fiddling with your example, I also found that the size action can cause the frame borders to change thickness, which is something I'd like to avoid. --Anthony ----- Original Message ---- From: Sjoerd C. de Vries <sjoerd.c.devries at gmail.com> To: Anthony Hodsdon <ajhodsd at yahoo.com> Sent: Fri, September 24, 2010 11:18:40 AM Subject: [mg112780] Re: Creating a Grid with square cells Hi Anthony, Something like this? Pane[Grid[Table[i + j, {i, 0, 4}, {j, 0, 4}], Frame -> All, Background -> {3 -> LightBlue}, ItemStyle -> 24, Alignment -> {Center, Center}], ImageSize -> 300, ImageSizeAction -> "ResizeToFit"] Cheers -- Sjoerd On Sep 24, 10:10 am, Anthony Hodsdon <ajho... at yahoo.com> wrote: > In the Mathematica documentation, I see that the parameters to ItemSize are > in rather unusual units: > > In Grid, w is measured in ems, and h in line heights. > > I'm attempting to create a Grid (not a GraphicsGrid) with square cells, but I >am a bit at a loss. Is there a good conversion between ems and line heights? It >seems to be about 3:2, but I suspect it's dependent upon the font in use. As a > work-around, I also tried using ItemSize->{Scaled[x],Scaled[x]} (for some > suitable x), which seemed to work, except that then the grid grew to fill the > entire notebook width. I also tried sticking the grid inside a pane, but then > the right side of the grid seems to get chopped off: > > Pane[Grid[Table[i+j, {i,0,4}, {j,0,4}],Frame->All, > Background->{3->LightBlue},ItemStyle->24, > > ItemSize->{Scaled[.2],Scaled[.2]}, Alignment->{Center, Center}], > ImageSize->{200,200}] > > Are there any good idioms for getting this to work? > > Thanks, > > --Anthony