[R] Plotting a Trivial Matrix

Jim Lemon jim at bitwrit.com.au
Fri Feb 26 11:12:03 CET 2010


On 02/26/2010 07:29 PM, Lorenzo Isella wrote:
> Dear All,
> Consider a matrix (N x N) where each entry is either zero or one (can
> hardly get any simpler).
> Now, I would like to plot it as a 'chessboard' where every matrix entry
> is a black (1) or white (0) square.
> Whatever tool I use to plot it, it should not try to interpolate the
> data at all.
> I found some online references
> http://www.phaget4.org/R/image_matrix.html
> but probably I can resort to something much simpler.
> Can anyone provide me with a simple example I can modify later on?

Hi Lorenzo,

trivial_matrix<-matrix(sample(0:1,100,TRUE),nrow=10)
require(plotrix)
color2D.matplot(trivial_matrix,main="A trivial Plot")

Jim



More information about the R-help mailing list