[R] plots in a matrix
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Nov 15 17:43:08 CET 2005
Hi,
consider the following example:
I have a matrix like this:
spp.mds$points
[,1] [,2]
CLAP0 1.79703164 -11.66716182
CLAP30 3.87034797 -7.48168377
YBI0000 10.27538316 -3.32226184
YBI0100 0.58463806 -1.25748701
hir10000 5.82907036 -4.09695960
hir10016 -2.22113472 -4.86563557
gyn30000 5.14643671 -3.58706541
gyn30032 2.99552434 -6.21815132
...
Each pair of rows represents a single sample (now and past say). I want
to draw the rowname for the past sample (row 2 of a pair) and an arrow
from the past sample pointing to the now sample (row 1 of a pair). These
are the coords of each point on axis 1 and 2 of an nmds.
Because there are so many pairs (52) the plot is crowded so I subset the
points, choosing which I want to plot on each sub-plot by hand to make
the plot less crowded:
rows <- list(c(1,3,7,9,11,13,15,17,19,21,25,35,37,43,97,99,93),
c(5,27,29,31,33,45,47,49,51,53,39,71),
c(55,57,59,61,63,65,67,69,73,75,77,79,41),
c(23,81,83,85,87,89,91,95,101,103))
listing the row 1 of each pair, so for I can do:
tops <- rows[[1]]
bottoms <- rows[[1]] + 1
plot(spp.mds, type = "n", display = "site", ann = FALSE, axes = FALSE)
axis(side = 2, at = c(10, 5, 0, -5, -10))
box()
text(spp.mds$points[bottoms,],
labels = rep(sacs.code, each = 2)[bottoms],
cex = 0.5)
arrows(spp.mds$points[bottoms, 1], spp.mds$points[bottoms, 2],
spp.mds$points[tops, 1], spp.mds$points[tops, 2],
col = "blue", length = 0.03)
for plot 1, and so on for the other subsets.
I was plotting using par(mfrow = c(2,2)), and so I have 4 plots
separated by lots of space. I want to get rid of all that space between
plots, turning off axis labels and axes for the internal axes. I know
how to do all of this except how to remove all the internal space whilst
keeping each plot the same size and shape. Simply setting two of the mar
(gin)s to be 0 for the internal margins for each plot is almost what I
want, but the plots come out slightly different sizes.
I'm sure there is something simple I'm missing, but I've tried various
combinations of split.screen(), layout(), changing oma, mar but I still
can't quite get this right.
Any suggestions?
Thanks in advance,
Gav
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5522
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list