       RE: Drawing Rectangular Grid

• To: mathgroup at smc.vnet.net
• Subject: [mg20221] RE: [mg20198] Drawing Rectangular Grid
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Wed, 6 Oct 1999 21:06:37 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Wilson Figueroa  wrote:

--------------------------
I am writing some code for a Cellular Automata Simulator.

I would like to have a function that I can give the following
information to:

Grid[size_of_grid, matrix_of_cells_to_fill]

This function will draw a n x m rectangular grid = size (for example
size = {2,2} for a 2 x 2 grid).

I then will pass an array of the cells to be filled.  For example
{{1,1},{2,2}}.  It could also be {{1,1},{1,2},{2,1},{2,2}}, in which
case the whole grid will have filled cells.

The Grid function will then return a Rectangular Grid with the cells
(1,1) and (2,2), which are the diagonal cells filled in as either black
cells or, better yet, as filled in circles that are smaller in size than
the square grid cell size. (Little circles enclosed within the grid
cells).

-------------------------

If I understand what you want the following should work nicely.

In:=
MatrixTest[expr_]:=MatrixQ[expr, IntegerQ[#]&&Positive[#]&]

MakeGrid[{width_Integer?Positive, height_Integer?Positive},
mtrx_?MatrixTest]:=
ListPlot[mtrx, PlotStyle:>PointSize[0.8/width],
PlotRange:>({{0,width},{0,height}}+0.5),
AspectRatio->Automatic,
GridLines:>({Range[0,width],Range[0,height]}+0.5),
Axes->None,PlotJoined->False]

In:=
test={{2,3},{1,4},{4,3},{4,1},{3,1},{5,2}};

In:=
MakeGrid[{5,4},test];

(* Graphics not shown *)

--------------------
Regards,
Ted Ersek

For Mathematica tips, tricks see
http://www.dot.net.au/~elisha/ersek/Tricks.html

```

• Prev by Date: Save as HTML
• Next by Date: RE: Follow-Up Question to
• Previous by thread: Re: Drawing Rectangular Grid
• Next by thread: Re: Drawing Rectangular Grid