On 04/03/2013 04:43 PM, Ross Marriott wrote:
Dear R Help,

I would like to know how to add a colour scale to a matrixplot please.

Here is the code that I've used to construct the matrix plot:

library(VIM)
SpatialPlot<- function(YearxBlock,plot.title){
# Years are columns, Blocks are rows in this matrix
YearxBlock<- as.matrix(YearxBlock)
# To set margins for the plot:
par(yaxt="n", oma=c(4,4,4,4),mar=c(1.5,1.5,1.5,1.5))
# Data coded according to a continuous color scheme, with lowest value "light gray", maximum value 
as "black", missing values as "white":
matrixplot(YearxBlock,col=c("lightgray","black","white"),axes=FALSE)
axis(side=1,col="black",at=c(1,4,7,10,13,16,19),
      labels=as.character(c(1993,1996,1999,2002,2005,2008,2011)),cex.axis=0.8)
mtext(text="block",side = 2, line = 1, outer = TRUE, font = 1)
title(main=plot.title,adj=0)
}

Hi Ross,
You can do this with the color.legend function (plotrix).

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to