[R] Matrix-like plot
Gavin Simpson
gavin.simpson at ucl.ac.uk
Fri May 31 16:40:16 CEST 2002
Dear List,
I have a 47 species * 83 samples matrix containing percentage abundance
data. I have two cluster analyses one of the samples and one of the
species, and have ordered the rows and columns of the species by samples
matrix according to these two cluster analyses. So far so good!
Now what I want to do is create a plot with the species dendrogram at
the top of the plot, the samples dendrogram to the left of the plot and
then in the main plotting area plot the abundances held in the cells of
the matrix. I know how to split the plotting region up so that it looks
somewhat like this:
----------------------
| |
| dendro 1 |
| |
----------------------
------ ----------------------
| || |
| d || |
| e || Matrix-like plot |
| n || |
| d || |
| r || |
| o || |
| 2 || |
| || |
------ ----------------------
What I do not know who to do is to plot the matrix-like plot. I want to
have a point for every value greater than zero in the matrix. So that
if in sample/row 1, species 1 and 2 were present at 25% and 75%
respectively but species 3 was absent, I would want 2 points, one for
each species present scaled relative to their abundance. I presume what
I would actually do is plot an expand.grid() object and vary the cex by
the values in the matrix so that zero values had zero cex, but I am not
sure how to go about doing this. An alternative could be to use image()
to plot coloured boxes for each cell based on the abundances. I tried
this initially like so:
> test <- expand.grid(x=1:47, y=1:83)
> names(test)
[1] "x" "y"
> image(test, z=cladocera) #cladocera being the matrix containing the
abundances
Error in image.default(test, z = cladocera) :
increasing x and y values expected
I am now stuck as to how generate the x and y points for image.
If anyone has any pointers I would be most grateful,
All the best
Gavin Simpson
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5402
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpson at ucl.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.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list