On 02/08/2011 03:25 AM, Alaios wrote:
Dear all
I am using color2D.maplot to map some matrixes to plot. everything works fine.
It seems that when my matrix contains only the same value color2D.maplot
returns the following error:
color2D.matplot(estimatedsr,redrange=c(0,1),greenrange=c(0,.5),bluerange=c(0,.5),xlab="x",ylab="y",main=sprintf('Estimated'),show.legend=TRUE,show.values=TRUE)
Error in rgb(reds, greens, blues) : color intensity 18.5, not in [0,1]
Calls: color2D.matplot -> color.scale -> rgb
if you want to generate the error above try the following:
require('plotrix')
estimatedsr<-matrix(data=18.5,ncol=6,nrow=6)
color2D.matplot(estimatedsr,redrange=c(0,1),greenrange=c(0,.5),bluerange=c(0,.5),xlab="x",ylab="y",main=sprintf('Estimated'),show.legend=TRUE,show.values=TRUE)
Hi Alex,
This is because the "rescale" function that is called by "color.scale"
that is called by "color2D.matplot" returns the original values when
there is zero variation. I never thought anyone would want to present a
color-value matrix when the cells were all the same color. In fact, I am
finding it hard to believe that you really want to do this. However, if
you really, really do, here is how:
color2D.matplot(estimatedsr,cellcolors=matrix("indianred3",6,6),
xlab="x",ylab="y",main=sprintf('Estimated'),show.legend=TRUE,
show.values=TRUE)
Plus, you get a gold star for reminding me to add the semi-intelligent
text color routine to color2D.matplot. Thanks.
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.