r-如何在image.plot中编辑x轴上的元素 [英] r- how to edit elements on x axis in image.plot

查看:979
本文介绍了r-如何在image.plot中编辑x轴上的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为这些数据创建了一个图像图:

I have created a image plot for this data:

sample
         p         p.1         p.2         p.3         p.4
  p    1.0000000  0.24077171 -0.66666667 -0.49009803  0.61237244
  p.1  0.2407717  1.00000000  0.09028939 -0.83444087  0.14744196
  p.2 -0.6666667  0.09028939  1.00000000  0.21004201  0.10206207
  p.3 -0.4900980 -0.83444087  0.21004201  1.00000000 -0.08574929
  p.4  0.6123724  0.14744196  0.10206207 -0.08574929  1.00000000

使用此代码:

  image.plot(sample,col=redblue(191), zlim=c(-1,1))

我得到这张图片:

I get this image:

在x和y轴上代替0.0 0.2 0.4 ..我想要p p.1 p.2 ...
我如何得到那个?
感谢您的时间和考虑?

Instead of 0.0 0.2 0.4.. on x and y axes, I want p p.1 p.2... How do I get that that? Thank you for your time and consideration?

我的热图如下所示:

它不对称。你能解决这个问题吗?
我使用的是以下代码:

its not symmetric. Can you please fix this? I am using this code:


shades = c(seq(-1,-0.5,length = 64),seq (-0.5,0.5,长度= 64),seq(0.5,1,长度= 64))

heatmap.2(样本,树形图='无',symm = TRUE,Rowv = FALSE,Colv = FALSE,key = TRUE,cexCol = 0.7,cexRow = 1,scale =row,keysize = 1,col = redblue(191),break = shades)

shades=c(seq(-1,-0.5,length=64), seq(-0.5,0.5, length=64), seq(0.5,1,length=64))
heatmap.2(sample, dendrogram='none', symm=TRUE, Rowv=FALSE, Colv=FALSE, key=TRUE, cexCol=0.7, cexRow=1,scale="row", keysize=1, col=redblue(191), breaks=shades)


推荐答案

这是一个更好的解决方案:

Here is a better-ish solution:

 par(mar=c(5,4.5,4,7))
 image(sample, col=rainbow(25), axes=F)  #redblue() doesn't work on my computer.
 axis(2)
 axis(1, at=seq(0,0.8,0.2), labels=rownames(sample))
 image.plot(sample, legend.only=T)

编辑:下面的情节是否与您要找的一样?

Does the plot below look like what you are looking for?

 sample = cor(matrix(rnorm(400), nrow=20))
 image(cor(matrix(rnorm(400), nrow=20)), axes=F)
 mtext(text=c(paste("country",1:21)), side=2, line=0.3, at=seq(0,1,0.05), las=1, cex=0.8)
 mtext(text=c(paste("country",1:21)), side=1, line=0.3, at=seq(0,1,0.05), las=2, cex=0.8)
 image.plot(sample, legend.only=T)

这篇关于r-如何在image.plot中编辑x轴上的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆