[R] axis does not show up
Sumukh Sathnur
sumukh.sathnur at gmail.com
Sat Aug 20 02:09:03 CEST 2011
Hello everyone,
Using the following script I generated a heatmap for my matrix with
image.plot from the fields package:
library(fields)
as.matrix(read.table("Matrix.txt", sep="\t"))->x
#on left: labels are:
Side<-as.character(x[1,2:ncol(x)])
length(Side)->nS
#on bottom, labels are:
Bot<-as.character(x[2:nrow(x),1])
#remove first row and column (they're labels)
x[-1,-1]->x
25->x[x>=25]
#define breaks and colors
HeatBrk<-seq(5,25,4)
MyCol= gray((4:0)/4)
#My axes are 104 components long, which is why my axis font is this small
par(cex.axis=0.3)
image.plot(x, col=MyCol, breaks=HeatBrk, legend.shrink=0.3, axes = FALSE)
and this is where my problem is: Nothing I do will get axes in the
proper places. I want to place Side on the left and Bot on the bottom of
the plot. If I use the built in xlab= and ylab=, my axes are generated
perpendicular to the corresponding axis, and if I use
axis(2,las=2, at = 1:nS, label = Side, tick = TRUE)
axis(1,las=2, at = 1:nS, label = Bot, tick = TRUE)
then I see two small marks show up near the appropriate axes but nothing
else. I also tried par(mar=c(10,10,10,10)) to check if my margins were
perhaps not large enough, but that didn't change anything. In fact, it
appears that my axes are being generated from the end of the plot and
continuing off the image (I checked with image() instead of image.plot() )
Any suggestions for how I could fix this? These same axes work fine
when generated on random test plots. I have attached the matrix and a
pdf of my plot.
Thanks in advance,
Sumukh
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Matrix.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110819/6cc889ff/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: axis_fail.pdf
Type: application/pdf
Size: 48475 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110819/6cc889ff/attachment.pdf>
More information about the R-help
mailing list