[R] Plotrix Trick
Lorenzo Isella
lorenzo.isella at gmail.com
Mon Jun 28 11:35:28 CEST 2010
Yes,
I believe I did something along your lines.
See the code snippet at the end of the email which sorts everything out
as far as I am concerned.
Cheers
Lorenzo
#####################################################################
library(Cairo)
library(plotrix)
set.seed(1234)
myseq <- abs(rnorm(25))
myseq[20] <- 100 #introduce outlier!
A <- matrix(myseq, ncol=5,nrow=5)
pre <- c("A","B","C","D","E")
CairoPDF("test_color_scale_log-fixed.pdf")
oldpar<-par( mar=c(7,4,4,6) ,
cex.axis=1.4,cex.lab=1.6,cex.main=1.6)
testcol<-color.gradient(c(0.2,1),c(0.2,0.5),c(0,0),nslices=5)
my_min_mat <- min(A)
col.labels<-c(formatC(min(A),format="f",digits=1),formatC(max(A),format="f",digits=1))
color2D.matplot(log(A),main="Title",c(0.2,1),c(0.2,0.5),c(0,0),
xlab = "",
ylab="",
show.legend=FALSE,
show.values=0,vcol="black",vcex=1, axes=FALSE)
axis(1,at=c(0.5,1.5,2.5,3.5,4.5),labels=pre)
axis(2,at=rev(c(0.5,1.5,2.5,3.5,4.5)),labels=pre, las=1 )
color.legend(5.3,1,5.8,3,col.labels,testcol,align="rb",gradient="y")
for(i in 1:5) {
for(j in 1:5) {
text(i-0.5,j-0.5,formatC(A[6-j,i],format="f",digits=1),col="white")
}
}
box()
par(oldpar)
dev.off()
On Thu, 2010-06-24 at 12:13 -0400, David Winsemius wrote:
> On Jun 24, 2010, at 11:38 AM, Lorenzo Isella wrote:
>
> > Dear Hrishi,
> > I am almost there, thanks. The only small problem left is to convince
> > also the colorbar to plot the values I want.
> > Consider the small snippet at the end of the email: colors and numbers
> > inside the cells are OK, but the legend shows the extremes of the log
> > transformed data instead of the original one.
> > Any suggestions?
>
> Why don't you emulate the seconde example of the help page for
> color2D.matplot and leave out the show legend and then add one after
> the plotting has been done?
>
More information about the R-help
mailing list