Grid
Grid is an add-on package for the
R language and environment for
statistical computing and graphics. It provides a set of
graphical functions which support a great deal of flexibility in the
layout of graphics. The lattice add-on package for R is based on grid.
On this page you will find package downloads for
various versions of grid, information on the
compatibility of different versions of grid and R, and
lots of documentation for grid.
I also have a todo list which describes
some of my future plans for the development of grid.
The latest version is 0.7-4 and can be found
here.
This version will only run on R version 1.6.0 or later.
(If you have an earlier version of R, there may be earlier versions of
grid that are compatible; see the table below).
This version of grid should be compatible with Lattice version 0.6-7 and later.
You could try looking for a binary version for Windows
here.
For those who like to live on the bleeding edge, the
latest (working) development version
of grid I am working on
is here
(Note that this may only run on the latest development
version of R).
grid is being developed alongside the development of the core
R graphics API. This means that different versions of grid
will only run on certain versions of R. The following table
gives a partial list of grid-R version compatibilities (click on the
links to get a tar ball for the corresponding version).
Because many people use grid only as support for the lattice
package, known grid-lattice compatibilities are also shown.
grid version |
lattice version |
R version |
0.5 or 0.5-1 |
0.4-0 | 1.4.* |
0.6 or 0.6-1 |
0.5-3 | 1.5.* |
0.7-1 |
0.5-6 | 1.6.* |
0.7-4 |
0.6-7 | 1.6.* or 1.7.* |
The grid package obtained from CRAN contains only a very basic and short
user's guide (to save on download size).
Here are a few more documents describing how some
of grid's features work.
First of all, there now exists a more in-depth
overview of grid (there is also a
similar overview of traditional S graphics).
There are downloadable documents on specific topics,
links to more general overview articles, and
a short FAQ.
If you are interested in the future development of grid, there is
also a
list of plans and "todo"s.
NOTE: These documents correspond to the latest development version of grid
so it is possible that there will be some differences between the
statements made in these documents and what your version of grid does
(especially if you have an old version of grid).
-
A simple example
showing interactive editing of grid objects.
-
A slightly more complex example
showing how grid objects can be shared between plots.
-
A simple example of the
use of
grid.move.to
and grid.line.to
.
-
A demonstration of the
use of rotated viewports.
-
A thorough tutorial going
through the various ways a simple scatterplot
might be programmed using grid.
-
A discussion with examples of
grid's frame objects and packing grid objects into frames.
-
A document
discussing the difference between locations and dimensions in grid.
-
A short discussion on using grid to draw
general-purpose diagrams.
-
A demonstration of various ways to draw tables
using grid.
Advanced
These documents are mostly written for my own reference, but if you
are pulling your hair out trying to understand what grid is doing then
you might be desperate enough to try these for an answer.
-
A bit of a discussion about
how grid units are implemented and why they are that way.
-
A discussion of the
current interpretation of grid's
"null"
units.
-
A discussion of what a
graphics context means in grid.
-
Some notes on
parent-child relationships between grid objects.
-
A discussion
about how to create persistent representations
of grid objects.
The paper from a talk on grid given in the
Proceedings of the 2nd International Workshop on
Distributed Statistical Computing can be found
here. NOTE: grid was originally called "lattice", but that name was
too good not to use for R's implementation of Trellis so we changed; anyway,
at the time of the conference it was still lattice so you are looking for the
talk titled "R Lattice Graphics".
There is also an
article on grid in Volume 2/2, June 2002 of the R News
newsletter. In that article, the last example cannot be run because
I rather stupidly used a private data set. Here is
an R script that includes the data and the grid code for that example;
you should be able
to simply cut-and-paste or save-and-source() this to reproduce the figure.
Thanks to Wendy Wrapson and Dr Niki Harre from the
Department of Psychology at the University of Auckland for allowing me to
make the data set available.
-
Does mathematical annotation work in grid (and lattice)?
Not yet, but it will from grid version 0.7 on.
-
Can I use "base" graphics functions with grid (and lattice)?
The short answer is no. This is pretty much the long answer too. If you
really know what you are doing, you might be able to get away with a couple
of things, but currently grid and base graphics are completely separate
graphics systems. There may be some effort made in the future to
allow them to talk to each other to some extent, but there is no
timescale on this yet.