Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 图形包的R图像功能添加轴标签_Image_R_Heatmap - Fatal编程技术网

Image 图形包的R图像功能添加轴标签

Image 图形包的R图像功能添加轴标签,image,r,heatmap,Image,R,Heatmap,我有一个只有0和1的矩阵: 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和1的矩阵:

                  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
有了这个矩阵,我可以用图形包的图像功能创建一个图像。使用此代码:

image(x)
这给了我一个完全符合预期的图像,0为红色,1为白色。但x轴和y轴上的标签不是行名和列名。这是一个介于0和1之间的范围,如何将其更改为我的列名

使用热图功能时:

heatmap(x)
标签是x轴和y轴的列名和行名。但现在所有只有0或1的行都是blanco。只有带变量的读取才会按预期绘制。(也完成了群集,但我可以关闭此功能)


是否有人知道如何获得使用图像(x)创建的图像和使用热图(x)创建的标签?首选使用image函数,因为行数将非常多。

我认为您应该在不使用轴(参数xaxt和yaxt)的情况下运行image(),然后添加带有指定标签的轴:

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)

+我就是这么做的。也许你应该颠倒行名和列名?谢谢,这正是我要找的地方。还了解了seq函数可用于的位置;)哦,seq函数实际上非常有用。