[R] plotting matrix into 2D color plots with rainbow colors

Jim Lemon jim at bitwrit.com.au
Thu Jul 28 11:02:06 CEST 2011


On 07/28/2011 04:00 PM, hitendra padalia wrote:
> Dear all,
>
> Can you pl. help me in plotting a matrix into 2D plot with more color
> options. I tried to plot with myImagePlot with
> RGB color ramp but it shows limited variation in color. There is a rainbow
> plot option also. Can anyone help me.
>
Hi Hitendra,
You can specify colors from the rainbow function for color2D.matplot in 
the plotrix package. However, try this:

colormat<-matrix(runif(100),nrow=10)
color2D.matplot(colormat,c(1,1,0,0,1),c(0,1,1,1,0),c(0,0,0,1,1))
color.legend(0,-1.6,4,-1.1,seq(0,1,by=0.2),color.scale(seq(0,1,by=0.1),
  c(1,1,0,0,1),c(0,1,1,1,0),c(0,0,0,1,1)))

Jim



More information about the R-help mailing list