R image function of graphics package add axis labels
heatmap, image, r
Solution
I think you should run image() without the axes (parameters xaxt and yaxt) and then add the axes with specified labels:
par( mar = par( "mar" ) + c( 2, 4, 0, 0 ) )
image( x, xaxt= "n", yaxt= "n" )
axis( 1, at=seq(0,1,length.out=ncol( x ) ), labels= colnames( x ), las= 2 )
axis( 2, at=seq(0,1,length.out=nrow( x ) ), labels= rownames( x ), las= 2)
Problem
I have a matrix with only zero's and ones: ``` acc062_1 acc062_2 acc003_1 acc003_2 acc039_1 acc039_2 SL2.40ct15849 0 1 0 0 1 0 SL2.40ct15848 0 0 0 0 0 0 SL2.40ct15847 0 0 0 0 0 0 SL2.40ct15846 0 0 0 0 0 0 SL2.40ct15845 0 0 0 0 0 0 SL2.40ct15844 1 1 1 1 1 1 SL2.40ct11061 0 0 0 0 0 0 SL2.40ct11060 0 0 0 0 0 0 SL2.40sc04607 1 1 1 1 1 1 SL2.40ct11212 0 0 0 0 0 0 SL2.40ch12 1 1 1 1 1 1 ``` With this matrix I can create an image with the image function of the graphics package. using this code: ``` image(x) ``` This gives me an image exactly as expected with the colors red for 0 and white for 1. But the labels on the x-axis and y-axis are not the rownames and column names. This is a range between zero and one, how do I change these to my column names? When using the heatmap function: ``` heatmap(x) ``` The labels are the column names and rownames for the x-axis and y-axis. But now all rows with only zero's or only one's are blanco. Only the read with variation is drawn as expected. (Also a clustering is done, but I'm able to turn this feature off) Does anyone know how to get the image as created with image(x) and get the labels as created with heatmap(x)? prefer of using the image function because the number of rows will be very high.